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

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

Confluence - Images not rendered through content REST API.

Edited

This is my curl call:
curl D -X GET -H 'Authorization: Basic *********' -H 'Content-Type: application/json' 'https://mydomain.atlassian.net/wiki/rest/api/content/$pageId?expand=metadata.properties.myprop,bb,body.view,version,container'

 

I get all the text and html in response. But images are not displayed. When the session is going on to Confluence, images are displayed, otherwise not!

Please help!

1 answer

Hello Tanushree and welcome to the Community!

The info you provided paints a clear picture of what you’re wanting and are accessing. The first thing I see which might explain why your images are not showing is that you’re not viewing the storage format of the Confluence page.

To explain a bit more detail into this, I’ll explain how images are displayed within Confluence. When you have a page within Confluence, you have 2 options to display an image within a page. The two options are a linked image (which exists somewhere else and is referenced as an image) and attached images (which are attached to a page within Confluence and displayed within a Confluence page). Both of these are viewed differently when viewing the Confluence page via the REST API. You are going back to why you’re not able to see the image within your REST API call. From your API call, the endpoint you’re accessing is correct. 

Let's go back to why you’re not able to see the image within your REST API call. From your API call, the endpoint you’re accessing is correct. However, if you want to see an image which is attached to a Confluence page, you will need to view the child/attachment to gain access to the images. The endpoint to access attachments is GET /rest/api/content/{id}/child/attachment. With this endpoint, you would make a call to request any attachments for the parent page which may have an image attached.

I hope this explains why images are not directly displayed via the endpoint you’re requesting along with how images may be stored and displayed within Confluence.

Regards,
Stephen Sifers

I have used this API already. It gives a json response with a _links attribute which has download and webui attributes in it.

I merged the atlassian base url and the download link from response and hit the merged link in browser, it took me to the login page of atlassian.

Which link am I supposed to provide to the image source to display the image or make it downloadable?

Also how we should add images to confluence page? Right now we are just copy pasting the image in the editor. We can change the way so as to get the response in REST API.

Hello Tanushree,

Thank you for replying and providing additional clarification.

If you want to access page attachments externally then, you will have to authenticate to get to the files attached. You would either need to pass through authentication when attempting access or enable anonymous access to the site.

For setting up Confluence anonymous access, please review Setting Up Public Access. This would allow you to make content available without having to authenticate to Confluence. However, this does not apply to all applications as this would let all content to be publically available.

I hope this helps clarify how to access your attachments within Confluence.

Regards,
Stephen Sifers

hello @Stephen Sifers can u show example for    to authenticate to get to the files attached.

i am been trying to authenticate image from page not able to do it. using token to authenticate.

What I dont understand is why attachements need Anonymous access? What is the security concern? Some user can very well expose sensitive data in text as well, which is freely avaialble via APIs, but for some wierd reason attachments are not.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence

Confluence Mythbusters: Does Atlassian even use Confluence?

Hi, Confluence collaborators! As part of #Confluence-Collaboratory month, we’ve created a very special Mythsbusters segment, where we're dive into an interesting myth and uncover the truth behind i...

1,474 views 7 29
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