【问题标题】:How do I insert a 'PDF Macro' into an existing Confluence page using REST API如何使用 REST API 将“PDF 宏”插入现有的 Confluence 页面
【发布时间】:2015-11-13 19:08:48
【问题描述】:

我一直在尝试使用 REST API 将“PDF 宏”插入到 Confluence 页面中,但显然遗漏了一些东西。我已经使用 REST API 成功创建了页面并将 PDF 附加到页面,但我很难理解我做错了什么。

curl -v -S -u user:password -X PUT -H 'Content-Type: application/json' -d'{"type":"page","body":{"storage":{"value":"<ac:structured-macro ac:name=\"viewpdf\"><ac:parameter ac:name=\"name\"><ri:attachment ri:filename=\"RequirementCoverageReport.pdf\"/><\/ac:parameter><ac:parameter ac:page=\"My Page\"<\/ac:parameter><\/ac:structured-macro>","representation":"storage", "container":{"type":"page","id":"78086157"}}}}' https://myurl/confluence/rest/api/content/78086157 | python -mjson.tool

这是被抛出的异常;

{
"message": "Edit Content id mismatch", 
"statusCode": 400
}

【问题讨论】:

    标签: confluence-rest-api


    【解决方案1】:

    如果我用这个更新我的 Confluence 5 页面:

     <ac:structured-macro ac:name="viewpdf"><ac:parameter ac:name="name"><ri:attachment ri:filename="name_of_the_attached_pdf" /></ac:parameter></ac:structured-macro>
    

    效果很好。但我只使用 jQuery/Javascript。 如果您需要 jQuery 解决方案,请告诉我。

    【讨论】:

      【解决方案2】:

      我在尝试通过 REST API 更新页面内容时遇到了同样的错误。我通过将页面 ID 添加到 JSON 的根部分来解决它:

      {
          "id": 12345, <---- this was missing
          "version": {
              "number": 3
          },
          "type": "page",
          "title": "New title",
          "body": {
              "storage": {
                  "value": "<p>New text.</p>",
                  "representation": "storage"
              }
          }
      }
      

      因此,如果您错过了新版本号,则应将页面 ID 移动到 JSON 的根部分。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-10-25
        • 1970-01-01
        • 2017-03-10
        • 1970-01-01
        • 1970-01-01
        • 2019-01-22
        相关资源
        最近更新 更多