There was a question asked a while ago, but with no helpful answer.
https://community.atlassian.com/t5/Confluence-questions/Get-Space-page-hierarchy-using-the-REST-api/qaq-p/351963
In a webpage, I want to build a tree view of the pages of a space, and maybe put them in a dropdown so the user can select one.
I am able to do a REST call to /rest/api/space/{spaceKey}/content to get the pages, but they are all in a list, with no hierarchy, and the ancestor field is always empty.
I am able to get only the root page with the same api, but setting the depth to "root". From there, I could do a REST call to get the children of that page, then do a REST call for every child to get their children and so on...
This would mean a number of REST calls equal to the number of pages, which is not great. Is there a better way to do it?
Helen's workarounds are very helpful - and point out a glaring omission within Confluence. The content management tool UI is severely underpowered. This question has been in the community since 2016 and STILL doesn't have an adequate response from Atlassian.
In case it helps someone else finding their way here - https://community.developer.atlassian.com/t/get-space-page-hierarchy-using-the-rest-api/15999/11 has more answers
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mathieu,
You could use the Page Tree Macro to display the tree view of the pages on a Confluence page.
Here is another resource for REST questions if this forum doesn't answer satisfactorily.
Thanks,
Ann
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for the suggestion. Page Tree Macro is fine, but can only be used in a Confluence Page, and after trying it, you cannot use it to select a page as part of a form.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.