Hi,
with this curl, it is possible to upload a new attachment:
curl -v -S -u admin:admin -X POST -H "X-Atlassian-Token: no-check" -F "file=@myfile.txt" -F "comment=this is my file" "http://localhost:8080/confluence/rest/api/content/3604482/child/attachment"
but how can i upload a new version of an attachment?
i try this:
curl -v -S -u admin:admin -X POST -H "X-Atlassian-Token: no-check" -F "file=@myfile.txt" -F "comment=this is my file" -F "version=2" "http://localhost:8080/confluence/rest/api/content/3604482/child/attachment"
but it did not work :(
Community moderators have prevented the ability to post new answers.
A POST to the child resource of a piece of content attempts to create a new piece of content.
To update the existing attachment you will need to use a different resource that references the existing attachment by ID, namely : rest/api/content/{id}/child/attachment/{attachmentId}/data
See the documentation in the atlassian rest browser:
https://bunjil.jira-dev.com/wiki/plugins/servlet/restbrowser#/resource/api-content-id-child-attachment-attachmentid-data
From the documentation :
curl -D- -u admin:admin -X POST -H "X-Atlassian-Token: nocheck" -F "file=@myfile.txt;minorEdit=true;comment=This is my updated File" http://myhost/rest/api/1/content/123/attachments/456/data
*Edit* Apologies, I should have checked that myself, the following works with curl 7.30
curl -D- -u admin:admin -X POST -H "X-Atlassian-Token: nocheck" -F "file=@myfile.txt" -F "comment=This is my updated File" -F "minorEdit=false" http://localhost:8080/confluence/rest/api/content/4751367/child/attachment/att4915201/data
The comment and minor edit flag are currently required
Unfortunately it does not work. And your curl call isn't compatible with Confluence 5.5 REST API. I tried
curl -v -S -u admin:admin -X POST -H "X-Atlassian-Token: no-check" -F "file=@mytext.txt" http://localhost:8080/confluence/rest/api/content/852013/child/attachment/att1081350/data
and get and statusCode 500
However, the response messages are not very helpful :(
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The following works, have ammended my answer
curl -D- -u admin:admin -X POST -H "X-Atlassian-Token: nocheck" -F "file=@myfile.txt" -F "comment=This is my updated File" -F "minorEdit=false" http://localhost:8080/confluence/rest/api/content/4751367/child/attachment/att4915201/data
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.
curl -D- -u admin:admin -X POST -H "X-Atlassian-Token: no-check" -F "file=@myfile.txt" http://it016-d01:1990/confluence/rest/api/content/1507332/child/attachment
Worked for me as well, to update a attachment
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try leaving off the version, Confluence should handle that itself.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There was a reason why I've attached the version. Without it, it get {"statusCode":400,"message":"Cannot add a new attachment with same file name as an existing attachment: myfile.txt"}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ah, I'm not sure that your "no-check" is right and I'd check the path as well - the script I've got here uses "nocheck" and /id-number/attachments" in the path rather than /id-number/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.