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.
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
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. :-(
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
@DPKJ I am trying to upload an image file to issue using vbscript but no luck.
It looks like you're new here. Sign in or register to get started.