我正在尝试按照远程 API 文档中给出的指南将 .xls 文件上传到 Confluence wiki 页面:https://developer.atlassian.com/confdev/confluence-server-rest-api/confluence-rest-api-examples#ConfluenceRESTAPIExamples-Uploadanattachment 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] /cdn-cgi/l/email-protection" -F "comment=this is my file" "http://localhost:8080/confluence/rest/api/content/3604482/child/attachment" | python -mjson.tool
这就是我正在做的:
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
我省略了 Python -mjson.tool,因为它说“无法解码任何 JSON 对象”,而且它没有意义,因为我没有发布 JSON。
但是上面的curl命令对我不起作用。我在控制台上看到目标页面的 html,但文件未上传。我尝试以多种方式修改curl命令,但没有任何效果。
另外,对于我尝试上传到的页面的 URL,它没有文档中建议的任何 contentID。目标URL是一个接受附件并显示上传文件列表的页面。
有人可以指出我哪里出错了吗?我对 Curl 没有太多经验。
大卫·冯卡 https://stackoverflow.com/users/2372612/david-vonka答案是正确的,除了标题“X-Atlassian-令牌“值。一定是”no-check“ (代替 ”nocheck")
所以更正后的命令是:
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: 将所有 <...> 占位符替换为您的值
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)