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

Way to find all pages

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)?

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted

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!

by ["spacekey"] I meant that you need to subsititute the actual space key for the word spacekey :smile:

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 :wink:

TAGS
Community showcase
Posted in Industry Groups

💙 Ethical design in tech

It's no secret that  the tech sector has built (and is building) processes and systems that exclude vulnerable users by designing “nudges” that influence users, users who end up making privacy c...

19 views 0 1
View post

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