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

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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 do you think is the most *delightful* Confluence feature? Comment for a prize!

- Create your own custom emoji 🔥 - "Shake for Feedback" on mobile 📱 - An endless supply of GIFs via GIPHY 🤩 Is there anything quite as nice as a pleasant surprise? Comment below with what...

402 views 23 8
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