Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Im getting Internal Server Error 500 when updating a confluence page via Curl

Deleted user October 14, 2021

 

The curl call im using is this one:

curl --location --request PUT http://localhost.com:8090/rest/api/content/21169510 --header "Accept: application/json" --header "Content-Type: application/json" --user user:password  --data "{\"id\": \"21169510\",\"type\": \"page\",\"title\": \"Test Doors\",\"space\": {\"key\": \"TOOL\"},\"body\": {\"storage\": {\"value\": \" <p class=\"auto-cursor-target\"><br /></p><table><colgroup><col /><col /><col /></colgroup><tbody><tr><th>KPI</th><th>KPI</th><th>KPI</th></tr><tr><td>1</td><td>1</td><td>1</td></tr><tr><td>1</td><td>1</td><td>1</td></tr></tbody></table><p class=\"auto-cursor-target\"><br /></p>  \",\"representation\": \"storage\"}},\"version\": {\"number\": \"13\"}}"

Im getting problems when updating the content of a page with something more complex than a simple sentence (in this case it works perfectly). If i dont use the \" with the body-storage-value, it gets an error with the < character, and if i use it, it answers with 500 internal server error. in this case i was trying to create a table.

Does anybody know what am I doing wrong?

1 answer

0 votes
Thomas Deiler
Community Champion
October 14, 2021

Dear @[deleted] ,

I know this kind of problems - made the same xp in the past. In most cases its a problem with encoding / escaping special chars.

I recommend to use first a browser extension for posting REST calls. There you can step by step debug you JSON payload.

Then I also recommend to call curl from a script. Python or PHP are pretty fine. They have both functions to encode the data to UTF-8.

So long

Thomas

Deleted user October 14, 2021

Thank you for your answer. Using Postman I am able to do it, but i need  to use the curl commands so i can automate it later. Its just matter of knowing how do i need to introduce the data for the body content, and how do i need to put the \" characters. I am able to do it creating a Json from the command line and adding in there the variables but that is significantly more difficult. So if anyone knows how to solve my doubt it would be great.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events