如何使用curl将文件上传到Atlassian Confluence页面 [英] How to upload a file to Atlassian Confluence page using curl
问题描述
我试图根据远程API文档中给出的指南将.xls文件上传到Confluence wiki页面:
https://developer.atlassian.com/confdev/confluence-server-rest-api/confluence-rest-api -examples#ConfluenceRESTAPIExamples - Uploadanattachment
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 "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.tool,因为它说'没有JSON对象可以解码',没有意义,因为我不发布json。
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.
但是上面的curl命令不为我工作。我看到我的控制台上的目标页面的HTML,该文件不会上传。我试图修改curl命令在几种方式,但没有什么工作。此外,对于我尝试上传到的页面的URL,它没有任何contentID如文档中建议的。目标网址是一个接受附件并显示上传的文件列表的页面。
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.
有人可以指出我出错的地方吗?我对Curl没有太多的经验。
Could someone please point out where am I going wrong? I don't have much experience with Curl.
提前感谢。
推荐答案
您需要在url中使用REST API: ... / confluence / rest / api / content / $ PAGE_ID / child / attachment
的视图页面。
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.
这篇关于如何使用curl将文件上传到Atlassian Confluence页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!