confluence-rest-api - 使用 Confluence API 使用 IFrame 宏创建页面
问题描述
我正在使用以下简单的 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 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
推荐阅读
- c - 如何从接收方向发送方发送 NACK 消息
- android - AndroidViewModel 实例化而不传递应用程序上下文?
- c++ - 调用数组内部的结构
- python - 如何将这部分代码提取到一些可重用的方法中?
- angular - 如何从左到右显示 mat-list-items
- javascript - 如何将查询字符串数据传递到我网站的所有页面?
- c - 初始化结构后 C 中的分段错误
- java - 带有 Switch Case 和数组的顺序和二进制 Java 程序。输出不正确。程序没有错误
- java - 如何从 Java 访问 Gradle 额外属性?
- react-native - 如何在本机反应中设置通知上的动态标签栏图标?