I have a Jira Automation that creates a new Confluence page and this works well, but I want to edit/add content to an existing Confluence page with a web request.
I'm running into an issue where my original content on the page is completely deleted, but I only want to add content, not remove it. Is this possible?
I'm using a PUT method with Custom data request body:
{ "version":
{ "number": "{{#=}}{{webResponse.body.version.number}} + 1{{/}}" },
"type": "page",
"status":"current",
"title": "Test Page",
"body": {
"storage": {
"value": "<p>sample text</p>{{webResponse.body.body.storage.value}}",
"representation": "storage"
}
}
}
From what I have seen there is no way to add content to an existing page. Instead you would have to retrieve the current body of the page into a variable, update the variable to insert the additional content then make the API call to Confluence passing the modified body content to update the page.
This is a technical constraint that we ran into in the past and it's unfortunate that they don't provide an API to append to the end of the page body.
Do you know how I could retrieve the current body and set as a variable to reuse?
And I agree, it would be super useful if they had an API call for this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The Get page by id API will return a body element which has three child elements:
Each of those children has two child elements (string):
It looks like the Get pages API also returns the body element but it only has the storage and atlas_doc_format children.
I haven't personally used either of these APIs so I can't speak to how you would use the different body child elements.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Julia Casciato
To update the existing page :-
1) you need custom field (short text type ) in your jira project to capture confluece page ID. in my case it is (issue.customfield_15715)
2)In your automation rule you first need to get the confluece page that you need to update and then PUT/update page
In "PUT" web request, custom data should be like :-
{
"id":"{{issue.customfield_15715}}",
"version": {
"number": {{webresponse.body.version.number.plus(1)}}
},
"spaceId": "space_id",
"status": "current",
"title": "xyz",
"parentId":"xyz",
"body":{
"representation": "storage",
"value": "<p> </p>
}
}
Also, make sure to select "Delay execution of subsequent rule actions until we've received a response for this web request"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm not sure how to get this custom field ID for a Confluence Page. I was using the Page ID, and I realized it was missing from the second request but the same issue happens.
First request: GET
https://[URL].atlassian.net/wiki/rest/api/content/2641690627
Delay option is checked
Second request: PUT
https://[URL].atlassian.net/wiki/rest/api/content/2641690627
{
"id": "2641690627",
"version": {
"number": "{{#=}}{{webResponse.body.version.number}} + 1{{/}}"
},
"type": "page",
"status":"current",
"title": "Hotfixes 2024",
"body": {
"storage": {
"value": "{{webResponse.body.body.storage.value}}<p>Updated Content</p> ",
"representation": "storage"
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It looks like Jyoti was suggesting that you store the Confluence page ID in the Jira custom field but I think if you already know the page ID you could just hard-code it instead.
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.