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.
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Today only! Share what you’re the most excited about for Team ‘25 or just dance out the beginning of a new quarter with us.
Comment the postOnline forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.