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

Upload Excel document (.xls) to confluence page via Rest API

I am trying to upload a Excel document (.xls) file to a page within my space in confluence via the Cloud Rest API. However, we are not trying to upload it as an attachment. We want the file to be uploaded to the page itself. 

The following command uploads it to the page as an attachment:

curl.exe -v -S -u username:password -X POST -H "X-Atlassian-Token: no-check;" "file=@<path to file>" "https://<environment>/wiki/rest/api/content/<page>/child/attachment"

This is not what we want. Below is a picture of a page with the file upload manually. This is what we are looking for via the rest API.


This is what we are getting from the above command: 

image.pngThey get attached to the attachments.


2 answers

1 accepted

1 vote
Answer accepted

Hello Trevor,

Using the Confluence API is a great way to automate tasks and make repetitive tasks less time consuming. It seems as though you have a solid understand of how to interact with the API.

With this said, the API endpoint you’re using is specifically for attaching a file to a parent page. This would cause a file to be a child of the parent adding it to the attachments page (not the page itself).

What you’re needing to do is to update the contents of the page itself after the file has been attached. This will not be accomplishable through a single endpoint, you will require at least 3 endpoints to complete this task. Here are the endpoints in the order you must use them:

  1. PUT /wiki/rest/api/content/{id}/child/attachment
  2. GET /wiki/rest/api/content
  3. PUT /wiki/rest/api/content/{id}

In this order, you will need to PUT the attachment. From there you will need to get the content of the page you want to update. Once you have the page you need to update you will then PUT the new content (using the storage format) of the page back into Confluence to include the storage format of the attachment you wish.

Here if further information on the Confluence page storage format: Confluence Storage Format (For server but will apply to cloud).

The above will allow you to attach a file to a page and then update said page with placing the attachment within using the storage format. If you run into any issues moving forward, please let us know so we may help you accomplish your goal.

Stephen Sifers

Hello, I have the same problem. HOWEVER, I am not automating the process. I just want to insert a living Excel sheet that when selected, just opens as an excel doc that can be edited and re saved.



Suggest an answer

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

Introducing Confluence Cloud and Jira Software Cloud Premium

Wherever you are in your team’s journey , our goal is to support your big ambitions. We’re a cloud-first company with the mission of unleashing the potential of every team, and to address the range ...

616 views 4 17
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