【问题标题】:api to create a new page on confluenceapi在confluence上创建一个新页面
【发布时间】:2016-06-09 05:44:07
【问题描述】:

我是一个 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。

【问题讨论】:

    标签: curl confluence jira-rest-api confluence-rest-api


    【解决方案1】:

    你的 curl 看起来不错,除了 url。

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

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

    【讨论】:

      【解决方案2】:

      试试下面的 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
      

      【讨论】:

        猜你喜欢
        • 2015-10-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-03-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-05-09
        相关资源
        最近更新 更多