How do I add content for warning macro using storage format?

399 Views Asked by At

I'm creating a markdown to confluence tool (using python markdown). I'm having an issue adding content for the warning macro.

The following creates the warning box with the title, but the content is missing.

<ac:structured-macro ac:name="warning">
  <ac:parameter ac:name="title">Do Not Modify This Page</ac:parameter>
  <ac:rich-text-body><p>
  This page is generated by a script. Any changes made
  here will be erased the next time this page is
  generated.
  </p></ac:rich-text-body>
</ac:structured-macro>

The docs for the warning macro don't specify what should be used.

When I edit the warning box in the ui and get body.storage for the page this is what is returned.

<ac:structured-macro ac:name=\"warning\" ac:schema-version=\"1\" ac:macro-id=\"3520f15e-e8af-4b26-bf94-4dbc226d8284\">
  <ac:parameter ac:name=\"title\">Do Not Modify This Page</ac:parameter>
  <ac:rich-text-body><p>blah frickin blah</p></ac:rich-text-body>
</ac:structured-macro>

I have tried replacing <ac:rich-text-body> with nothing, plain-text-body, body, content and a few others I can't remember. None of these have worked.

Any ideas or pointers?

2

There are 2 best solutions below

0
On

Adding the macro-id to the definition made it work.

  <ac:structured-macro ac:name="warning" ac:macro-id="3520f15e-e8af-4b26-bf94-4dbc226d8284">
    <ac:parameter ac:name="title">Do Not Modify This Page</ac:parameter>
    <ac:rich-text-body><p>
    This page is generated by a script. Any changes made
    here will be erased the next time this page is
    generated.
    </p></ac:rich-text-body>
  </ac:structured-macro>
0
On

The following worked for me without a macro-id:

<ac:structured-macro ac:name="note"><ac:parameter ac:name="icon">true</ac:parameter><ac:rich-text-body><h3>Auto-generated page. Do not edit in Confluence; edits will be overwritten!</h3></ac:rich-text-body></ac:structured-macro>

Where my REST API put request had JSON of {'body: {'storage': {'value': STUFF_HERE}}} where STUFF_HERE was some HTML starting with the note macro I showed above. The JSON also included other stuff like page version number of course, I just omitted that stuff for brevity.