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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,462,110
Community Members
 
Community Events
176
Community Groups

Upload/Update attachment on Confluence page via rest api

When I run requests against this endpoint:

"https://your-domain.atlassian.net/wiki/rest/api/content/{id}/child/attachment"

I get various errors (403 for PUT and 500 for POST).

Can we have a working example for using this endpoint to upload a file to a confluence page please. E.g Upload `example.txt`.

Ideally Python but cURL should be fine either.

I am able to run get requests against the same endpoint and successfully return attachments, so I don't think there's an issue with my API key or permissions.

For context, I created the page and am able to edit it through my browser.

1 answer

0 votes

Hi @Llyr Jones

Welcome to the community!

Ideally, it should be POST method. 

It could be that the REST API could not find the file that is being attached.  I have not tried it in Python but used third-party application like Postman.

If you don't mind, can you list the complete curl command here (after hiding your Confluence domain, of course).

Thanks,
Vamsi

Hi @Vamsi Kandala 

I'm using Postman but here is the cURL generated from my request

 

curl --location --request POST 'https://<Domain>/rest/api/content/<Page ID>/child/attachment' \
--header 'Authorization: Basic <API Key>' \
--header 'X-Atlassian-Token: nocheck' \
--form 'file=@"example.txt"' \
--form 'minorEdit="true"' \
--form 'comment="Example attachment comment"' \
--form 'type="text/plain"' \
--form 'charset="utf-8"'

Hi @Llyr Jones

Is the attachment file in the same location from where you are executing this curl command?

Can you check this reference article: https://developer.atlassian.com/cloud/confluence/rest/v1/api-group-content---attachments/#api-wiki-rest-api-content-id-child-attachment-post and try out the example given?

Thanks,
Vamsi

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Site Admin
TAGS

Atlassian Community Events