I am trying to upload an .xls file to a Confluence wiki page following the guidelines given in the Remote API documentation : https://developer.atlassian.com/confdev/confluence-server-rest-api/confluence-rest-api-examples#ConfluenceRESTAPIExamples-Uploadanattachment
curl -v -S -u admin:admin -X POST -H "X-Atlassian-Token: nocheck" -F "[email protected]" -F "comment=this is my file" "http://localhost:8080/confluence/rest/api/content/3604482/child/attachment" | python -mjson.tool
This is what I am doing:
curl -v -S -u username:password -X POST -H "X-Atlassian-Token: nocheck" -F "file=@/path/to/local/excelsheet.xls" https://<Confluence server>/display/page
I omitted the Python -mjson.tool as it says 'No JSON object could be decoded' and it didn't make sense as I am not posting JSON.
However the above curl command is not working for me. I see the html of the target page on my console and the file doesn't get uploaded. I tried modifying the curl command in several ways but nothing worked.
Also for the URL of the page I am trying to upload to, it doesn't have any contentID as suggested in the documentation. The target URL is a page which accepts attachments and shows the uploaded file list.
Could someone please point out where am I going wrong? I don't have much experience with Curl.
David Vonka answer is correct except for header "X-Atlassian-Token" value. It must be "no-check" (instead of "nocheck")
So corrected command is:
curl -v -S -X POST -H "X-Atlassian-Token: no-check" -F "file_0=@<file name>" -F "comment_0=<upload comment>" "http://<server>:<port>/<context>/pages/doattachfile.action?pageId=<page id>&os_username=<username>&os_password=<password>"
NOTE: replace all the <...> placeholders with your values