Hi,
I am creating confluence pages via API.
I want the page to have page tree with @self as root.
I can do this in confluence but not sure how to do it via API.
Any help is appreciated!
The updated body of the content. Does not apply to attachments. If you are not sure how to generate these formats, you can create a page in the Confluence application, retrieve the content using Get content, and expand the desired content format, e.g.
expand=body.storage
.
You will get something like this:
<p><ac:structured-macro ac:name="pagetree" ac:schema-version="1" ac:local-id="LOCAL_ID" ac:macro-id="MACRO_ID"><ac:parameter ac:name="root"><ac:link><ri:page ri:content-title="@self" /></ac:link></ac:parameter><ac:parameter ac:name="expandCollapseAll">true</ac:parameter><ac:parameter ac:name="startDepth">1</ac:parameter></ac:structured-macro></p>
If you now create a page over api you can just pass this code block with the item.
Should look something like this:
{
"title": "YOUR_TITLE",
"type": "page",
"space": {
"key": "YOUR_SPACE_KEY"
},
"status": "current",
"ancestors": [
{
"id": "SOME_PAGE_ID"
}
],
"body": {
"storage": {
"value": "<p><ac:structured-macro ac:name='pagetree' ac:schema-version='1' ac:local-id='LOCAL_ID' ac:macro-id='MACRO_ID'><ac:parameter ac:name='root'><ac:link><ri:page ri:content-title='@self' /></ac:link></ac:parameter><ac:parameter ac:name='expandCollapseAll'>true</ac:parameter><ac:parameter ac:name='startDepth'>100</ac:parameter></ac:structured-macro></p>",
"representation": "storage"
}
}
}
Hi @Zain Ali. Check out the Copy page hierarchy API method.
From the docs: Copy page hierarchy allows the copying of an entire hierarchy of pages and their associated properties, permissions and attachments. The id path parameter refers to the content id of the page to copy, and the new parent of this copied page is defined using the destinationPageId in the request body.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Join the discussion on interview best practices and common pitfalls. Share your experiences and learn from others in the Atlassian Community.
Share your experiences!Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.