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

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

Joshua Senecal November 10, 2014

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

3 votes
Howard Zhang September 25, 2015

use this

rest/api/content/{id}?expand=ancestors
Krishna M Digvijai February 27, 2018

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

Like Alex Karasev likes this
0 votes
Bart Kerfeld August 13, 2015

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?

0 votes
WestonM July 30, 2015

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.

0 votes
Ismar_Slomic July 12, 2015

Im interested in this as well. Any input?

 

0 votes
Greg Miller May 5, 2015

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
AUG Leaders

Atlassian Community Events