我试图上传一个. xls文件到一个Confluencewiki页面下面的指南在远程API留档: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 "file=@myfile.txt" -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. tools,因为它说没有JSON对象可以解码,这没有意义,因为我没有发布JSON。
然而,上面的curl命令对我不起作用。我在控制台上看到目标页面的html,但文件没有上传。我尝试以多种方式修改curl命令,但没有任何效果。
另外,对于我尝试上传到的页面的URL,它没有留档中建议的任何contentID。目标URL是一个接受附件并显示上传文件列表的页面。
有人能指出我哪里出错了吗?我对卷发没有太多经验。
大卫·冯卡的回答是正确的,除了标题“X-艾特莱森-Token”值。它必须是“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>"
注意:替换所有
您需要在url中使用RESTAPI:…/confluence/rest/api/content/$PAGE_ID/child/附件
,现在您正在使用视图页面的url。
我不认为confluence rest api允许文件上传。请改为这样做
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>"
更换所有