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

Need to know how to insert attachments in Page body under Space using Api

Nisha_PugalPetra_Perumal August 7, 2019

I have added the attachment in the page but they are not being displayed in page body .

Kindly help me in solving this using api.

2 answers

1 accepted

1 vote
Answer accepted
Shannon S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 8, 2019

Hello Nisha,

Happy to help you with this. 

When you're adding an attachment to a page via REST API, you are only adding it to the list of attachments. If you want to put the attachment in the body content, then you need to modify the body content. 

I was able to find a thread on this that can help you:

For more details, you can refer to our Confluence Cloud REST API Documentation.

Regards,

Shannon

Nisha_PugalPetra_Perumal August 9, 2019

Hi Shannon,

Thanks for the update .I have tried to post the content as specified in the thread you shared.But i couldn't find anything posted in the page .Please find the query i am using,

 

curl -u username:token -X PUT -H 'Content-Type: application/json' -d'{
"id":"contentid",
"type":"page",
"title":"Requirement",
"version":{"number":12}},
"body":{
"storage":{
"value":"<p>Hi</p>",
"representation":"storage"
}
}
}' "https://domain.atlassian.net/wiki/rest/api/content/{content id}?status=current"

Shannon S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 9, 2019

Nisha,

The instructions I provided are for Confluence Server. If you are on Confluence Cloud, you can check the following article for advice on how to do that:

Your example still has the test domain URL in it as well as the contentID placeholder. I am assuming that here you have included your Cloud instance URL and the contentID you obtained from the GET command that you ran prior to the PUT command?

Regards,

Shannon

Nisha_PugalPetra_Perumal August 12, 2019

Hi Shannon,

 

I am able to update the contents of the Page with text now .Thanks for the help.

 

I am using the following command:

curl -u username:password -X PUT -H 'Content-Type: application/json' -d'{"id":"927662202","type":"page","title":"Requirement","space":{"key":"~621441701"},"body":{"storage":{"value":"<p>This is the updated text for the new page</p>","representation":"storage"}},"version":{"number":17}}' https://domain.atlassian.net/wiki/rest/api/content/927662202 | python -mjson.tool

But  my actual aim is to update the csv sheet to th page or embedd the contents of the csv into page

Shannon S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 16, 2019

Hi Nisha,

I just want to make sure I understand correctly what you need to do.

Are you trying to replace the CSV which is currently attached to the page with an updated version, or simply embed the contents of new CSVs on the page each time? I am assuming the CSV is the attachment you are uploading via REST-API.

Regards,

Shannon

Bharat_Kumar February 27, 2020

Hi, Shannon, I want to upload new CSV to page each time but I did not know how to attach CSV to rest API call.

KOSHTI NIKHILESH July 2, 2020

@Shannon, I am able to attach the file , but it shows in the attachments section of the page. How do I show it on the page instead of in attachments. Kindly please help me in this issue

Shannon S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 2, 2020

Hello, @KOSHTI NIKHILESH!

Welcome to Atlassian Community. It's nice to have you.

If you are also trying to use REST-API to display the attachment on the page like Nisha was, then you have to use the instructions that I shared earlier. The attachment will always display on the list of attachments as long as it's attached to the page. If you want to display the attachment in the page itself, you have to edit the page content using REST-API.

However, I suspect you might not be referring to REST-API at all, which was the original topic of this thread.

If that is the case, please review Display Files and Images in Confluence Cloud, and if you continue to have any questions, you'll need to raise a new question which is more relevant to your problem.

Let me know if you have any questions about that.

Shannon

0 votes
NIshant January 24, 2022

this comment is to get my username.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events