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

I am getting 500 internal server error when trying to update a page.

suman151 January 14, 2022
  1. Command that I am using is curl -u  username:password -H "Content-Type: application/json" - X PUT -d '{"id" :"pageid", "type" :"page", "title" :"Delphix", "body" :{"storage" :{"value" :"<p>test</p>", "representation" :"storage"}}, "version" :{"number" :6}}' https://companyurl/confluence/rest/api/content/pageid

2 answers

1 accepted

2 votes
Answer accepted
Pramodh M
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 15, 2022

Hi @suman151 

Please find the steps for updating the page

First, make an API call to get the Content ID (Page ID) using below API

curl -u admin:admin -X GET "http://localhost:8080/confluence/rest/api/content?title=myPage%20Title &spaceKey=TST&expand=history"

Once you have got the page ID, make a GET call to the Page using below API

curl -u admin:admin -X GET "http://localhost:8080/confluence/rest/api/content/3473411?expand=body.storage"

Now for the important part, updating the page with the ID

curl -u admin:admin \
-X PUT -H
'Content-Type: application/json' \
-d
'{ "id":"3604482", "type":"page", "title":"new page",
"space":{"key":"TST"},
"body":{
"storage": {
"value": "<p>This is the updated text for the new page</p>",
"representation":"storage"}},
"version":{"number":2}
}'
http://localhost:8080/confluence/rest/api/content/3604482

One thing though the URL will be your base URL and then this "rest/api/content/3604482"

Other than that your REST Call looks good

Let me know if this works for you!!

Thanks,
Pramodh

suman151 January 16, 2022

Thanks Pramodh

It worked for me. 

Like Pramodh M likes this
0 votes
Pramodh M
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 15, 2022

Hi @suman151 

Welcome to the Community!!

Please follow this community link for reference

https://community.atlassian.com/t5/Confluence-questions/How-to-edit-the-page-content-using-rest-api/qaq-p/904345

Thanks,
Pramodh

suman151 January 15, 2022

Hi, 

I tried the resource u have provided. But still getting the same response. And if i am not using confluence in the api then getting 405 error. So can you please help more on this. 

Pramodh M
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 15, 2022

@suman151 

Are you able to successfully access confluence via UI?

If so, get the page via the GET request and we need to use that for PUT request in order to update the page.

Thanks,
Pramodh

suman151 January 15, 2022

Yes, I am able to successfully access confluence via UI and get request is also working fine. But getting 500 error when using PUT requesr type. 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events