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

Uploading attachments using rest api. Edited


I've trying to upload an attachment to a page with id 857705024 using the rest api, but I keep receiving a 301.

Can anyone help me? :-)

Here is the command:

curl -D- -u user:api_key -X POST -H "X-Atlassian-Token: nocheck"  -F "file=@image.png" -F "comment=myImage"




2 answers

1 accepted

0 votes
Answer accepted

HTTP Response Code 301 implies "Moved Permanently"

So in order to follow this redirection we need to pass `-L` flag to curl request. So updated command will look like.

curl -L -D- -u user:api_key -X POST -H "X-Atlassian-Token: nocheck"  -F "file=@image.png" -F "comment=myImage"


Now I get a 404, but the number of the page is correct.

DPK_J Community Leader Aug 26, 2019

Oh! I noticed,

In place of POST, you need use PUT method for this api.

curl -L -D- -u user:api_key -X PUT -H "X-Atlassian-Token: nocheck"  -F "file=@image.png" -F "comment=myImage"


Thanks for your help, but with POST or PUT the result is the same: a 404.

I even tried with a text file, but the result is always the same.


I don't seem to be able to upload attachments to our confluence. :-(

DPK_J Community Leader Aug 27, 2019

As per API documentation, these are the reason for 404 response,

  • The requested content is not found.
  • The user does not have permission to view it
  • The attachment exceeds the maximum configured attachment size.

Have you checked all these?

Try this, as you are using confluence api, we need to context path 'wiki' also. And method will be post.

curl -D- \
  -u <EMAIL>:<API_TOKEN> \
  -X POST \
  -H "X-Atlassian-Token: nocheck" \
  -F "file=@example.txt" \
  -F "minorEdit=true" \
  -F "comment=Example attachment comment" \

It was the wiki! Thanks a lot! :-D

DPK_J Community Leader Aug 27, 2019

@Paula_Cristina_VazYou are welcome, I am sorry that I wasn't able to figure out that in first place.

I am using and developing for both server and cloud versions, so many a times I get confused with APIs.

No problem. Thank you again. :-)

@DPK_J  I am trying to upload an image file to issue using vbscript but no luck. 

Suggest an answer

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

What project did you transition or start on Confluence with the shift to remote work?

It’s been great to hear from fellow users over the last few weeks about the best tips and fun moments you’ve had working on Confluence since the transition to working remote. I’d love to keep the c...

109 views 3 7
Join discussion

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