How to upload a file to Atlassian Confluence page using curl

99封情书 提交于 2019-12-05 03:14:57

you need to use REST API in url: .../confluence/rest/api/content/$PAGE_ID/child/attachment and now you are using url of view page.

rubensa

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

I do not think that confluence rest api allows file upload. Please do this instead

curl -v -S -X POST -H "X-Atlassian-Token: nocheck" -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>"

replace all the <...> placeholders with your values

The API POST syntax should be corrected from "https://ConfluenceServer/display/page" to the correct res/api/content syntax eg: "https://companyName.atlassian.net/display/rest/api/content/pageIDxxxxx":

 curl -v -S  -X POST -H "X-Atlassian-Token: no-check" -F "file_0=@<file name>" -F "comment_0=<upload comment>" https://<companyName>.atlassian.net/display/rest/api/content/<pageID15398762>/child/attachment

The pageID can be found in the URL display page. For example: https://companyName.atlassian.net/display/spaces/DEV/pages/pageID15398762/Page+Title+Name

For more API syntax details please refer to this documentation:
https://docs.atlassian.com/atlassian-confluence/REST/6.6.0/#content-createContent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!