Forums

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

Upload an image to a page using the REST API

Rob Bell
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 26, 2020

I'm trying to use the Confluence REST API to create a page containing an image. I've tried a few different things without success but thought I might be on to something by base64 encoding an image and setting it as the source for an image tag in the page HTML, but although Confluence appears to create the page successfully, it doesn't display the image and appears to strip it out. 

curl -u user:pass \
-X POST \
-H 'Content-Type: application/json' \
-d '{"type":"page","title":"new page 123",
"space":{"key":"DEVELOPMEN"},"body":{"storage":{"value":"<img src=\"data&colon;image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==\" />","representation": "storage"}}}' \
https://robbell.atlassian.net/wiki/rest/api/content | python -mjson.tool

Is there a more sensible approach that I'm missing?

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
TAGS
AUG Leaders

Atlassian Community Events