1

我是一个 confluence 组的成员,我从以下 URL 从浏览器中打开该组

https://kensci.atlassian.net/wiki/collector/pages.action?key=MyKyey

点击这个页面会给我登录页面,我在其中输入我的凭据并开始创建一个新页面等。

我想通过 API 做到这一点。我已经阅读了互联网上的几篇文章,觉得下面的 curl 命令应该可以工作。

curl -v -u admin:admin -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' -d'{"type":"page","title":"new page","space":{"key":"ATTACH"},"body":{"storage":{"value":"<p>This is a new page</p>","representation":"storage"}}}' "http://localhost:8090/rest/api/content/?os_authType=basic"

但是,我应该用什么替换 URL http://localhost:8090/rest/api/content/?os_authType=basic?我是否将其替换为从浏览器打开的 URL,即https://kensci.atlassian.net/wiki/collector/pages.action?key=MyKey/?os_authType=basic

我已经尝试过了,所以最后字符串看起来如下

curl -v -u myusername:mypassword -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' -d'{"type":"page","title":"new page","space":{"key":"ATTACH"},"body":{"storage":{"value":"<p>This is a new page</p>","representation":"storage"}}}' "https://kensci.atlassian.net/wiki/collector/pages.action?key=MyKey/?os_authType=basic"

但它不会创建页面,只会吐出大量的 HTML。

4

2 回答 2

0

尝试以下 curl 命令。我试过了,它适用于我的 wiki url。

curl -v -S -u username:password -X POST -H "Content-Type: application/json" -d'{"type":"page","title":"new page","space":{"key":"ATTACH"},"body":{"storage":{"value":"<p>This is a new testpage</p>","representation":"storage"}}}' https://kensci.atlassian.net/rest/api/content
于 2016-08-31T08:35:39.560 回答
0

除了 url,你的 curl 看起来很好。

编辑:请尝试用以下内容替换“ http://localhost:8090/rest/api/content/?os_authType=basic ”:“ https://kensci.atlassian.net/wiki/rest/api/content/?os_authType =基本“。您可能需要在“/wiki”之后添加“/collector”。

如果这不起作用,请发布您得到的输出。

于 2016-03-09T18:44:24.053 回答