You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
How to update the page content in confluence?
I tried the below code but I am getting error at this line$UpdateConfluence = Invoke-WebRequest -Method PUT -Uri ($ConfluenceURL + $Call) -Body $Body -ContentType $ContentType. Could you please help me find the resolution?
$Credentials = Get-Credential
$MaxJsonLength = 67108864
$ConfluenceURL = "https://confluenceurl/wiki/rest/api/"
$ConfluencePageID = "xxxxx"
$Headers = @{"Authorization" = "Basic "+[System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes(($Credentials.UserName+":"+[System.Runtime.InteropServices.marshal]::PtrToStringAuto([System.Runtime.InteropServices.marshal]::SecureStringToBSTR($Credentials.Password)) )))}
$Call = "content/$($ConfluencePageID)?expand=body.storage,version,space,ancestors"
$CurrentConfluence = Invoke-WebRequest -Method GET -Headers $Headers -Uri ($ConfluenceURL + $Call)
$JSONSerial = New-Object -TypeName System.Web.Script.Serialization.JavaScriptSerializer
$JSONSerial.MaxJsonLength = $MaxJsonLength
$CurrentConfluence = ($JSONSerial.DeserializeObject($CurrentConfluence))
$Body = @{
"id" = ($CurrentConfluence.id)
"type" = "page"
"title" = ($CurrentConfluence.title)
"version" = @{
"number" = ($CurrentConfluence.version.number + 1)
}
"status" = "current"
"space" = @{
"id" = ($CurrentConfluence.space.id)
"key" = ($CurrentConfluence.space.key)
"name" = ($CurrentConfluence.space.name)
"type" = ($CurrentConfluence.space.type)
}
"ancestors" = @{
"id" = ($CurrentConfluence.ancestors.id)
"type" = ($CurrentConfluence.ancestors.type)
"status" = ($CurrentConfluence.ancestors.status)
"title" = ($CurrentConfluence.ancestors.title)
}
"body" = @{
"storage" = @{
"value" = "This is a newly-posted Confluence page"
"representation" = "editor"
}
}
}
$Body = $Body | ConvertTo-Json
$ContentType = "application/json"
$Call = "content/$($ConfluencePageID)"
$UpdateConfluence = Invoke-WebRequest -Method PUT -Uri ($ConfluenceURL + $Call) -Body $Body -ContentType $ContentType
$JSONSerial = New-Object -TypeName System.Web.Script.Serialization.JavaScriptSerializer
$JSONSerial.MaxJsonLength = $MaxJsonLength
$UpdateConfluence = ($JSONSerial.DeserializeObject($UpdateConfluence))
Hi @atlassianaccount ,
welcome to the Atlassian community!
Please take a look to some examples provided in the rest Api section https://developer.atlassian.com/cloud/confluence/rest/v1/api-group-content/#api-wiki-rest-api-content-id-put
Hope this helps,
Fabio
I have already gone through the site but couldn't find an solution for the above script.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.