Via the Confluence Cloud REST API, is there anyway to obtain all pages that have no parents (AKA finding all pages that are at the top of their hierarchy tree)?
Community moderators have prevented the ability to post new answers.
There's a few options, but either way, it seems like you'll have to go space by space.
You can use the json-rpc/confluenceservice-v2/getTopLevelPages call if you are OK with using JSON-RPC (POST ["spacekey"] as data).
Otherwise, to do it purely with the REST API, you can get all spaces via the following REST call:
https://xxxx.atlassian.net/wiki/rest/api/space?expand=homepage&type=global&start=0
and then call it with start+=25 until size != 25 (because it returns only 25 at a time). Make sure you keep track of each results[#].key (space key) and results[#].homepage.id (page ID of the homepage of that space).
Then you should call the following for each space:
https://xxxx.atlassian.net/wiki/rest/api/content/search?cql=space%3D<spacekey>%20and%20type%3Dpage%20and%20ancestor!%3D<homepageId>
where <spacekey> is the spacekey of the space and <homepageId> is the homepage page ID. If you want to exclude the homepage from the results (because the homepage also has no parents), then you can simply add the following on the end of the above REST call:
%20and%20id!%3D<homepageId>
Tried posting ["spacekey"] and it seems like I'm not allowed to view that space, but that's okay. The other method should work perfectly! Is there a way that I can do a count of all the spaces to see how big of a dataset I'm working with (I don't have access to the server or any commands that require restrictive admin rights)?
Thanks so much!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
by ["spacekey"] I meant that you need to subsititute the actual space key for the word spacekey
You should be able to find out a the total number of spaces with:
https://xxx.atlassian.net/wiki/rest/searchv3/1.0/search?startIndex=0&type=spacedesc
and if you want to see all archived spaces too, then just add &includeArchivedSpaces=true to the end
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.