Confluence view the image using the REST API
Asked by Senthil Kuma Pandi:

I have been reading many posts to find the right way to get the confluence page content with images using the REST API.

Either the accepted solution is not working or the post didn't come to a conclusion?

Can someone please give me the correct solution?

Some of the URLs that I referred to.

<https://community.atlassian.com/t5/Confluence-questions/View-Confluence-Page-Images-via-API/qaq-p/1051944>

<https://community.atlassian.com/t5/Confluence-questions/Confluence-Images-not-rendered-through-content-REST-API/qaq-p/1029337>

<https://community.atlassian.com/t5/Jira-Software-questions/how-to-display-attached-image/qaq-p/1497142>

<https://community.atlassian.com/t5/Confluence-questions/Render-embedded-images-with-Confluence-with-REST-API/qaq-p/588632>

<https://community.atlassian.com/t5/Confluence-questions/Is-it-possible-to-display-an-image-via-REST-API/qaq-p/460826>


Answers:
author: Rajpv
body: ATLASSIAN Team - Need your support to help me how to publish the image as a body in the confluence page.

Please note with the below curl cmd - i could successfully attach the png file but my requirement is to have a snapshot of the pnf file in the confluence page.

curl -v -S -u username:password -X POST -H "X-Atlassian-Token: no-check" -F "file=@C:\\Users\\test\\image\\scb.png" -F "comment=this is my file" "<https://confluence.XXXXXX.com/rest/api/content/2377271484/child/attachment>"

Could you please share the curl command for posting the snapshot of png file in the confluence page???


author: Senthil Kuma Pandi
body: Hi [@Pramodh M](/t5/user/viewprofilepage/user-id/3691224) ,

Thanks for your reply. I tried that too. when I use the '  
/wiki/rest/api/content/\*\*\*\*/child/attachment' call, I got the below response.  
Array  
(  
\[results\] =\> Array  
(  
\[0\] =\> Array  
(  
.......

........

\[_links\] =\> Array  
(  
\[webui\] =\> /pages/viewpageattachments.action?pageId=\*\*\*\*\*\&preview=%2F\*\*\*\*%2F\*\*\*\*%2Fimage-20220124-174701.png  
\[self\] =\> https://\*\*\*\*.atlassian.net/wiki/rest/api/content/att\*\*\*\*  
\[download\] =\> /download/attachments/\*\*\*\*/image-\*\*\*\*-174701.png?version=1\&modificationDate=1643046423112\&cacheVersion=1\&api=v2  
)

)

<br />

\[_links\] =\> Array  
(  
\[base\] =\> https://\*\*\*\*\*.atlassian.net/wiki  
\[context\] =\> /wiki  
\[self\] =\> https://\*\*\*\*.atlassian.net/wiki/rest/api/content/\*\*\*\*\*/child/attachment  
)  
)

*** ** * ** ***

After that, if I framed the URL using the *\[_links\]\[base\]* **.** *\[0\]\[_links\]\[download\]* (https://\*\*\*\*\*.atlassian.net/wiki/download/attachments/\*\*\*\*/image-\*\*\*\*-174701.png?version=1\&modificationDate=1643046423112\&cacheVersion=1\&api=v2),  
and used the REST API with basic auth to render the image in my website. nothing is rendering. For the verification, I hit the URL (https://\*\*\*\*\*.atlassian.net/wiki/download/attachments/\*\*\*\*/image-\*\*\*\*-174701.png?version=1\&modificationDate=1643046423112\&cacheVersion=1\&api=v2), directly on the browser. It is taking me to the Login page.Could you please help to understand what I am missing?  
Thanks  
Senthil.


author: Pramodh M
body: Hi [@Senthil Kuma Pandi](/t5/user/viewprofilepage/user-id/4783843)

You can only get the link for the attachment present on the page.

You need some sort of application to render the image!!

All the links you are referring are explaining the same


Tags: confluence-server

image

rest-api

server