8

这就是我目前所拥有的,它会创建一个新的 Confluence 页面。它不更新它。它也将它发布在根空间中TST,但我希望它位于TST/space1/subsection2/updateThisPage.

curl -v -u admin:admin -X POST -H Content-Type: application/json -d  "{\"id\":\"123456\",\"type\":\"page\",\"title\":\"new page\",\"space\":{\"key\":\"TST\",\"title\":\"updateThisPage\"},\"body\":{\"storage\":{\"value\":\"<p>This is the updated text for the new page</p>\",\"representation\":\"storage\"}},\"version\":{\"number\":3}}" http://localhost:8090/rest/api/content?spaceKey=TST&title=updateThisPage

这是我收到的错误消息

{"statusCode":400,"message":"A page with this title already exists: A page already exists with the title new page in the space with key TST"}

会不会是权限错误?我知道我无权删除。

4

3 回答 3

12

使用请求 /rest/api/content/{id}。

这对我有用。

curl -u admin:admin -X PUT -H "Content-Type: application/json" -d "{\"id\":\"26738701\",\"type\":\"page\",\"title\":\"new page\",\"space\":{\"key\":\"RO\"},\"body\":{\"storage\":{\"value\":\"<p>UPDATE This is a new page</p>\",\"representation\":\"storage\"}},\"version\":{\"number\":2}}" http://localost:10080/rest/api/content/26738701

JSON有效负载:

{  
   "id":"26738701",
   "type":"page",
   "title":"new page",
   "space":{  
      "key":"RO"
   },
   "body":{  
      "storage":{  
         "value":"<p>UPDATE This is a new page</p>",
         "representation":"storage"
      }
   },
   "version":{  
      "number":2
   }
}

不要忘记使用:

  • 数据部分的内容 ID
  • 数据部分的版本号
  • 放置请求
  • 请求中的内容 ID
于 2015-02-20T13:25:58.340 回答
0

尝试使用 PUT 而不是 POST。

curl -v -u admin:admin -X PUT -H Content-Type: application/json -d  "{\"id\":\"123456\",\"type\":\"page\",\"title\":\"new page\",\"space\":{\"key\":\"TST\",\"title\":\"updateThisPage\"},\"body\":{\"storage\":{\"value\":\"<p>This is the updated text for the new page</p>\",\"representation\":\"storage\"}},\"version\":{\"number\":3}}" http://localhost:8090/rest/api/content?spaceKey=TST&title=updateThisPage
于 2015-02-19T22:20:03.700 回答
0

如果有人正在寻找 javascript 解决方案,这是我对另一个问题的回答,例如 在发布到 Atlassian Confluence api 时出现 Unexpected grunt-http 错误

在这里你可以找到我在 confluence hackathon https://github.com/devex-web-frontend/dxWebPlugins/blob/master/src/confluence/helpers/buffer.js上开发的工作代码

于 2015-05-07T17:18:00.033 回答