Rest API - how to insert children display micro while creation of page

Sukhjinder Bhullar March 3, 2020

Hello,

I am using confluence rest api and python module requests to create multiple pages in confluence. 

I will have parent and child hierarchy of pages. I want to insert children display macro at parent page using rest api call. 

code sample: 

invpagebodyhtml = "<p><b>This page is published by automation tool.</b></p>"
create_page = json.dumps(    {        "type""page",        "title""testing-notification",        "space": {"key""TEST"},        "ancestors": [{"id"1234567}],        "status""current",        "body": {"storage": {"value": invpagebodyhtml, "representation""storage",}},    })

response = requests.request(    "POST", URL, data=create_page, headers=headers,)

any help on how to include that macro here? 

Thanks

Sukh

1 answer

1 accepted

0 votes
Answer accepted
Sukhjinder Bhullar March 3, 2020

I got it worked with adding this to my html 

 

old html: 

invpagebodyhtml  = '<p><b>This page is published by automation tool.</b></p>'

 

new html:

invpagebodyhtml  = '<p><b>This page is published by automation tool.</b></p><p><ac:structured-macro ac:name=\"children\" ac:schema-version=\"1\" /></p>'

Benoit Cantineau May 17, 2022

Great, many thanks for the answer. Eventually, you don't know how to add the 'Depth' parameter into this syntax ?

Matt Merrill June 3, 2022

I had to trial and error this, but I just figured out how to do this, this is an example for the 'all'/descendants property:

 

<p><ac:structured-macro ac:name=\"children\" ac:schema-version=\"1\"><ac:parameter ac:name=\"all\">true</ac:parameter></ac:structured-macro></p>

It took me forever to find the docs: https://confluence.atlassian.com/conf59/children-display-macro-792499081.html

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events