jira - 使用 REST API 更新 Confluence 中的页面

标签 jira confluence jira-rest-api confluence-rest-api

这就是我目前所拥有的,它创建了一个新的 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"}

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

最佳答案

使用请求/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
  • 数据部分中的版本号
  • PUT 请求
  • 请求中的内容 ID
  • 关于jira - 使用 REST API 更新 Confluence 中的页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28615001/

    相关文章:

    jira - 有没有办法计算 JIRA 中 "Reopened"票的数量?

    groovy - 如何从 Groovy 设置 JIRA 票证的版本字段

    java - 将 Java Rest API 连接到 JIra

    button - 我可以在 Confluence 中向文本添加按钮吗?

    xml - Confluence 存储格式 - 任何人都玩过 anchor 和 anchor 链接宏

    python-3.x - 通过python脚本访问confluence页面

    jira - Jira jql查询以搜索在日期后状态更改为特定状态的票证

    javascript - header 部分超过 10240 字节(可能未正确终止)

    java - 无法创建 AsynchronousJiraRestClientFactory(依赖性问题)

    c# - 使用 C# 在 Jira-Rest-Api 中搜索过滤器