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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Getting Internal Server Error 500 after updating a page

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

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?

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
Community showcase
Published in Confluence

Announcing Team Calendars in Confluence Data Center

Hi Community! We're thrilled to share that Team Calendars for Confluence is now a built-in feature for Confluence Data Center releases 7.11 and beyond.  A long time favorite,  Team Cale...

101 views 0 3
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you