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

Getting Internal Server Error 500 after updating a page

David Suchan August 24, 2020

Hello, I am trying to update our confluence page by inserting content of a file. I can update the page successfully with some simple "test message", but attempting to pass variable with content of cat file.md results in Internal Server Error.

Here is what I tried:

1. 

content=$(cat xyz/README.md)
curl -u login:pass -X PUT -H 'Content-Type:application/json' -d '{"id":"123","type":"page","title":"test","body":{"storage":{"value":"'"$content"'","representation":"storage"}},"version":{"number":19}}' https://xyz.com/confluence/rest/api/content/139793950

$content has the correct content of the file i want to show, i tried to pass $content in multiple ways using ' and " ( such as'$content', etc.) but all of them resulted in the error.

2. Here i tried to write the curl command into > file in three stages: 

 

echo '{"id":"123","type":"page","title":"test","body":{"storage":{"value":"' > file
echo $content >> file
echo '","representation":"storage"}},"version":{"number":19}}' >> file

 

Then i run curl:

 

curl -u login:pass -X PUT -H 'Content-Type:application/json' -d "$(cat file)" https://xyz.com/confluence/rest/api/content/139793950

 

When i run

echo $(cat file)

, it shows that I am indeed passing {"id":"123","type":"page","title":"test","body":{"storage":{"value":" my readme content ","representation":"storage"}},"version":{"number":19}} 

Where am I making a mistake in passing the variable?

I am going to repeat that I successfully put "test123" in the "value" and managed to update the page, meaning I am either passing things in "value" wrong or what I am trying to accomplish is not possible. 

I am running all this from a gitlab pipeline, trying to update the confluence page automatically every time we update our readme file located in our git repo,  therefore it is out of question to do things manually. Another thing will be figuring out how to increment version number, but I will do that once I manage to at least pass the content of the file.

I dont have access to logs, I would have to request it. Thank you for any knowledge that would help me get to the core of problem.

 

 

2 answers

1 accepted

0 votes
Answer accepted
David Suchan September 8, 2020

It would really make things easier to debug if I could see json validation error instead of Internal server error 500. Can we close this?

0 votes
David Suchan August 24, 2020

I found the problem to be characters below ASCII 32, I hope I can replace them. 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events