I am using the following simple curl call to create a new Confluence page with an embedded IFrame macro that references an external site:
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;
Whilst the page is being created with the embedded macro none of the macro parameters have been set, per the definitions in the request payload. "URL" is a mandatory parameter for the macro, however I am unclear if the element should be used, or alternatively the element (and hence set both - to no avail).
Thanks and regards, Andrew
The Confluence XHTML content payload needs to be as follows:
<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>
The easiest way to determine the correct payload is to manually create the page with macro and use the REST API to retrieve the XHTML content fragment
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