Forums

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

Confluence view the image using the REST API

Senthil Kuma Pandi March 3, 2022

3 answers

0 votes
Rajpv May 18, 2022

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???

0 votes
Senthil Kuma Pandi March 6, 2022

Hi @Pramodh M ,

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
                        )

                )


    [_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.
0 votes
Pramodh M
Community Champion
March 3, 2022

Hi @Senthil Kuma Pandi 

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

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, likes for trees, atlassian community, social impact, tree planting campaign, community kudos, atlassian giving, environmental impact, sustainability, likes for good, atlassian social responsibility, community challenge

Make every click count—help us plant 50,000 trees! 🌳

Want to make your everyday Community actions directly contribute to reforestation? The Atlassian Community can achieve this goal by liking a post, attending an ACE, sending your peers kudos, and so much more!

Help us plant more trees
AUG Leaders

Atlassian Community Events