Update page with Rest API returns 200 but the page is not updated

Guillaume Sinnaeve April 19, 2022

I used Google App Script and Rest API to update a Confluence page.

Firstly, i use GET method to get the page information with (myhost.net/wiki/rest/api/content/123456?expand=body.storage,version).

Then, i use PUT method to update the page information like below

var data = {
"id": "123456",
"title": "My title",
"space": {
"key": "MySpace"
},
"type": "page",
"body":{
"storage": {
"value": "my text",
"representation":"storage"
}
},
"version": {
"number": currentBodyData.version.number + 1
}
};

var response = UrlFetchApp.getRequest("myhost.net/wiki/rest/api/content/123456",{
method: 'PUT',
headers: {
"Authorization": "Basic " + token,
"Content-Type": "application/jsonl; charset=utf-8"
},
body: JSON.stringify(data)
});

 

Response has the code 200 but the Confluence page is not updated.

Thanks for your help.

1 answer

1 accepted

0 votes
Answer accepted
Dominic Lagger
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 19, 2022

Hey @Guillaume Sinnaeve 

First thought is, that you updated an older version. Did you check that? 

And the second thought was, that you do not update the version number, but at a second look, I saw that you do. 

Does this happen to all pages, you want to edit via REST? 

Also the history didn't change? 

Regards, Dominic

Guillaume Sinnaeve April 19, 2022

Hey @Dominic Lagger ,

Thanks for your reply.

At this moment, i only do my test on one specific page.

Regarding the version number, I always get the page information first and add 1 to the version number when I want to do the update.

Regarding the history, when I check the settings of my page, I still have the version number before the update. It's not changing.

Best regards

Like Dominic Lagger likes this
Guillaume Sinnaeve April 20, 2022

Hey @Dominic Lagger ,

I solved my issue by used the function UrlFetchApp.fetch and used "payload" options instead of body in the request.

Thanks for your help.

Like Dominic Lagger likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events