【问题标题】:Page creation with IFrame macro using Confluence API使用 Confluence API 使用 IFrame 宏创建页面
【发布时间】:2020-04-11 13:18:17
【问题描述】:

我正在使用以下简单的 curl 调用来创建一个新的 Confluence 页面,其中包含一个引用外部站点的嵌入式 IFrame 宏:

curl -u <username>:<password> -X POST -H 'Content-Type: application/json' -d '{"type":"page","title":"A Test Page", "space":{"key":"SPACE"}, "ancestors" : [ { "id": "115328548" } ],"body":{"storage":{"value":"<h1>IFrame Macro Test</h1><p>Foo Bar Blah</p><p><ac:structured-macro ac:schema-version=\"1\" ac:name=\"iframe\"><ac:parameter ac:name=\"URL\">https://www.example.com</ac:parameter><ac:parameter ac:name=\"Width\">100%</ac:parameter><ac:default-parameter>https://www.example.com</ac:default-parameter></ac:structured-macro></p>","representation":"storage"}}}' https://localhost:8080/confluence/rest/api/content  | python -mjson.tool;

根据请求负载中的定义,在使用嵌入宏创建页面时,尚未设置任何宏参数。 “URL”是宏的强制参数,但是我不清楚是否应该使用该元素,或者该元素(因此设置两者 - 无济于事)。

感谢和问候, 安德鲁

【问题讨论】:

    标签: confluence-rest-api confluence-macros


    【解决方案1】:

    Confluence XHTML 内容负载需要如下所示:

    <ac:structured-macro ac:name="iframe" ac:schema-version="1" ac:macro-id="f3b89c73-0096-409c-84fa-0158bf4e0f4f" xmlns:ac="http://www.atlassian.com/schema/confluence/4/ac/" xmlns:acxhtml="http://www.atlassian.com/schema/confluence/4/" xmlns:ri="http://www.atlassian.com/schema/confluence/4/ri/">
        <ac:parameter ac:name="src">
            <ri:url ri:value="https://example.com"/>
        </ac:parameter>
        <ac:parameter ac:name="width">100%</ac:parameter>
        <ac:parameter ac:name="height">750</ac:parameter>
        <ac:rich-text-body>
            <p>
                <br/>
            </p>
        </ac:rich-text-body>
    </ac:structured-macro>
    

    确定正确负载的最简单方法是使用宏手动创建页面并使用 REST API 检索 XHTML 内容片段

    curl -u <user>:<password> -H 'Accept: application/json' --url 'https://<host:<port>/confluence/rest/api/content/<page-id>?expand=body.storage,version' | python -mjson.tool
    

    【讨论】:

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