Hello.
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" http://my-host.atlassian.net/rest/api/content/857705024/child/attachment
TIA
Paula
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" http://my-host.atlassian.net/rest/api/content/857705024/child/attachment
Thanks.
Now I get a 404, but the number of the page is correct.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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" http://my-host.atlassian.net/rest/api/content/857705024/child/attachment
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi DPK J.
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. :-(
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
As per API documentation, these are the reason for 404 response,
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" \ http://<host>.atlassian.net/wiki/rest/api/content/857705024/child/attachment
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Any update @Paula Cristina Vaz Did you ever solved this? Looks like it is returning 404 when we try as per the documentation.
I think i figured it out -- if somebody reach out this query - here is this fix.
404 happens since you have not got url correctly.
https://{host}.atlassian.net/wiki/rest/api/content/{id}/child/attachment.
When i tried this from postman it worked with the token and required information. It should also work with curl.
Thanks in advance.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.