Per*_*ron 9 python curl confluence confluence-rest-api
我正在尝试按照远程API文档中提供的指南将.xls文件上传到Confluence维基页面:https: //developer.atlassian.com/confdev/confluence-server-rest-api/confluence-rest-api- 【举例】#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
Run Code Online (Sandbox Code Playgroud)
这就是我在做的事情:
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
Run Code Online (Sandbox Code Playgroud)
我省略了Python -mjson.tool,因为它说'没有JSON对象可以被解码'而且它没有意义,因为我没有发布JSON.
但是上面的curl命令对我不起作用.我在控制台上看到目标页面的html,文件没有上传.我试过用几种方法修改curl命令,但没有任何效果.
此外,对于我尝试上传到的页面的URL,它没有文档中建议的任何contentID.目标URL是接受附件并显示上载文件列表的页面.
有人可以指出我哪里出错了吗?我对Curl没有多少经验.
您需要在 url: 中使用 REST API .../confluence/rest/api/content/$PAGE_ID/child/attachment
,现在您正在使用查看页面的 url。