I've successfully used the Confluence Rest API to create a page and attach it to a Space. MY json looks much like that from the example:
{
"type":"page","title":"My Example Page 1", "space": {"key":"DAT"},
"body":{"storage":{"value":"<p>This is a new page</p>","representation":"storage"}}
}
If I create a page interactively in Confluence, I'm given a list of canned macros when I click the 'Edit' button like 'Attachments' or 'Activity Stream'.
What is the right json value to create a page with the Attachments Macro as the body instead of 'This is a new page'?
Something like below (which is totally made up):
{
"type":"page","title":"My Example Page 1", "space": {"key":"DAT"},
"body":{"storage":{"value":"**Attachments_Macro_Block**","representation":"storage"}}
}
What would I substitute for 'Attachments_Macro_Block' in the json to get the resultant page to display the macro block?
As luck would have it, after I posted this question I stumbled on the answer. So for the benefit of others, here is what I found.
This page provided the missing pieces: Confluence Attachment Macro Help
My JSON looked like this:
{
"type":"page",
"ancestors":
[
{
"type":"page",
"id":12355342
}
],
"title":"Page Title 1",
"space":
{
"key":"DAT"
},
"body":
{
"storage":
{
"value":"<ac:structured-macro ac:name=\"attachments\">
<ac:parameter ac:name=\"old\">false<\/ac:parameter> <ac:parameter ac:name=\"patterns\">*<\/ac:parameter>
<ac:parameter ac:name=\"sortBy\">name<\/ac:parameter> <ac:parameter ac:name=\"sortOrder\">ascending<\/ac:parameter>
<ac:parameter ac:name=\"labels\"><\/ac:parameter> <ac:parameter ac:name=\"upload\">false<\/ac:parameter> <\/ac:structured-macro>",
"representation":"storage"
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With