Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How can I use Jira Automation Send Web Request to Update an Existing Confluence Page?

Julia Casciato September 11, 2024

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"
}
}
}

2 answers

0 votes
Rick Westbrock September 16, 2024

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.

Julia Casciato September 16, 2024

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.

Rick Westbrock September 17, 2024

The Get page by id API will return a body element which has three child elements:

  • storage
  • atlas_doc_format
  • view

Each of those children has two child elements (string):

  • representation
  • value

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.

Like Julia Casciato likes this
0 votes
Jyoti Mane September 11, 2024

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

automation rule to update confluence page.PNG

 

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"

Julia Casciato September 12, 2024

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"
}
}
}

Rick Westbrock September 16, 2024

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.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events