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.