Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Creating Page via API - page tree macro

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!

2 answers

In the API doku I found this part and like this it works:

 

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"
}
}
}
0 votes
Neil
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Aug 08, 2022 • edited

Hi @Zain Ali. Check out the Copy page hierarchy API method.

https://developer.atlassian.com/cloud/confluence/rest/api-group-content---children-and-descendants/#api-wiki-rest-api-content-id-pagehierarchy-copy-post

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. 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events