Hi All,
I am able to upload image through rest api. but i dont know how to display that image. please guide me.
Thanks in advance
@noor basha I have already sent you a reply on your previous question.
Here is recap of that,
Displaying attachment on confluence page is another part of story and you will need to fire separate APIs for this.
You need to put something like this in your page body using API,
<ac:image>
<ri:attachment ri:filename="atlassian_logo.gif" />
</ac:image>
Here is an working API example, in first API I'm adding image `sample.png` as attachment and later in second API call I'm displaying that in page using Confluence Structure format in body.
curl -D- -u '<USERNAME>:<PASSWORD>' \
-X POST \
-H 'X-Atlassian-Token: nocheck' \
-F 'file=@"./sample.png"' \
'<CONFLUENCE_BASE_URL>/rest/api/content/<PAGE_ID>/child/attachment'
curl --request PUT \
--url '<CONFLUNCE_BASE_URL>/rest/api/content/<PAGE_ID>' \
--user '<USERNAME>:<PASSWORD>' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data '{
"id":"<PAGE_ID>",
"type":"page",
"title":"Sample Page",
"space":{"key":"<SPACE_KEY_OF_PAGE>"},
"body":{
"storage":{
"value":"<p>Adding image to page</p><ac:image><ri:attachment ri:filename=\"sample.png\" /></ac:image>",
"representation":"storage"
}
},
"version":{"number":<NEXT_VERSION_NUMBER>}
}'
thanks alot sir. it worked, but curl is not working fine i tried with different approach.To display or update i used storage format then i am able to upload or modify any data in the confluence page.
thanks alot for you help and replay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi noorbasha - can you explain what you mean by using "storage format"? I am having same problems and can't make the code above work.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Today only! Share what you’re the most excited about for Team ‘25 or just dance out the beginning of a new quarter with us.
Comment the postOnline forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.