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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Get a page's immediate ancestor (parent) using Confluence REST API?

Is there a way to retrieve the ID of a page's immediate ancestor (parent) using the REST API? I'm able to get a list of all ancestors of a page, and assuming that list is ordered I can use it to determine the page's parent. However, in certain circumstances I've noticed the list is not in order, and can even contain duplicate entries, so I cannot reliably use the ancestor list itself to determine the parent of a page.

I'm using Confluence 5.6.3.

5 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

use this

rest/api/content/{id}?expand=ancestors

above query will return all ancestors details.How immediate ancestor id will be identified?

Like Alex Karasev likes this

I have also discovered there to be duplicates, however, I am not finding that the hierarchy is ever out of order. For me, every test I have run has shown the last result being the immediate ancestor to the page I look for. Method Type: GET Url: http://base_url/rest/api/content/CONTENTID?expand=ancestors I then get a json result which I convert to XML since I like dealing with it more in C# XmlDocument doc = JsonConvert.DeserializeXmlNode(jsonResponse, "root"); XmlNodeList nodes = doc.SelectNodes("/root/ancestors"); string title = ""; foreach (XmlNode node in nodes) { title = node["title"].InnerText; } return title; This has not failed for me and I have tried several things do try to mess with it (deleting then restoring pages, flipping parent and child in hierarchy, changing spaces etc...). Do you know what you did that caused the order to be changed so that I can try to replicate the problem?

I'm also interested in this. According the API, you can only browse "down". There's an "ancestor" property, but I've found it to be blank.

Im interested in this as well. Any input?

 

I can't believe no one has answered this. I'm trying to figure out how to set the parentId of a newly created page. It's not clear from the REST API examples.

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
Community showcase
Posted in Trello

Taco Tuesday: Your favorite Trello blog takeaway

Hello friends! From the community that brought you Welcome Wednesday, Throwback Thursday and Friday Fun, welcome to Taco Tuesday, a weekly discussion about all things Trello. The best part? One Tac...

113 views 6 6
Join discussion

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