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?