Render embedded images with Confluence with REST API

I'm using the following api to get page content to display in our website.

/rest/api/content?spaceKey=FAQ&expand=body.view&title=Reports

I'm able to retrieve the html but the images aren't displaying. Is this a bug or do I need to make an extra api call order to render the images? 

1 answer

1 accepted

I found that the images would appear when logged into my Confluence site. I enabled anonymous access for the space that I was trying to get the images from and it's working now. I did have to modify src="" in the <img> element by adding the base url name in front of the source url. Another option is to use basic authentication in the URL, as explained in https://developer.atlassian.com/docs/atlassian-platform-common-components/rest-api-development/rest-and-os_authtype.
To use the basic authentication with rest API, you will have to insert the following parameters:
os_username=internal-admin&os_password=mypassword
Replace the internal-admin and the mypassword for the correct information.

If you don't authenticate against Confluence, the content won't be shown as the source of the image is still pointing to Confluence URL.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Kesha Thillainayagam
Posted Apr 13, 2018 in Confluence

We want to hear how your non-technical teams are using Confluence!

Hi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...

2,691 views 25 10
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you