You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.