Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,300,666
Community Members
 
Community Events
165
Community Groups

How to get parent page id in confluence rest api

Edited

Hello,

I have been trying to retrieve the parent page ID using the child's page ID, but I am unable to retrieve this information using REST API.

I have tried using the following endpoints but the response did not return the parent page ID :

'https://confluence[server]/rest/api/content/[child_id]' 
'https://confluence[server]/rest/api/
space/[child_id]?expand=space'

Can someone please let me know how I can get the ID of the parent page using the REST API in python?

Thank you!

2 answers

1 accepted

2 votes
Answer accepted

Hi @Prem Methuku 
Welcome to the Atlassian Community.

If you have the target pageID, then you can use the following REST API call to the get the list of ancestors (aka parents) of the current page.

<Confluence_Base_URL>/rest/api/content/<pageID>?expand=ancestors

 

Kind regards,
Thiago Masutti

That works! Thanks Thiago.

If you (or somebody else for that matter) will be using the Python library you can just call

page = confluence.get_page_by_id(page_id=page_id, expand='ancestors')
parent_id = page['ancestors'][-1]['id']

 and get the parent_id from a list of ancestors.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence

An update on Confluence Cloud customer feedback – June 2022

Hi everyone, We’re always looking at how to improve Confluence and customer feedback plays an important role in making sure we're investing in the areas that will bring the most value to the most c...

375 views 2 11
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you