1
votes

I am looking for a Graph API call which can return to me all of the sites in Sharepoint Online.

Looking at Enumerating Sites: https://docs.microsoft.com/en-us/graph/api/site-list?view=graph-rest-beta&tabs=http

GET https://graph.microsoft.com/beta/sites?filter=siteCollection/root ne null

it doesn't seem to return group-based sites or sub sites.

Looking at Site Search: https://docs.microsoft.com/en-us/graph/api/site-search?view=graph-rest-beta&tabs=http

GET https://graph.microsoft.com/beta/sites?search={query}

this might be more promising but there is no explanation for how "query" should be structured or what it searches against.

My thought was that since all of the site ids begin with the tenant domain that I might be able to search on that and then retrieve every site and subsite for the tenant. But I'm not sure how to perform that query.

Ideally something like:

GET https://graph.microsoft.com/beta/sites?search=id like contoso.microsoft.com
1
It's worth noting that I've abandoned trying to use the Graph API and am now using the Sharepoint API. where I can use this ............... GET: mytenant.sharepoint.com/_api/search/… contentclass:STS_Web'&selectproperties='Title,Path'&rowlimit=500 ............... STS_Web are subsites and STS_Site are the root sitesfei0x
note that if a site is not indexed they won't show up in the results with the contentclass annotation.fei0x

1 Answers

8
votes

I found this post asking a very similar question.

https://sharepoint.stackexchange.com/questions/230187/retrieve-all-sites-and-all-subsites-from-the-sharepoint-rest-api

And there is a response by 'dvdsmpsn' where he shares that you can retrieve all sites with this call:

https://graph.microsoft.com/v1.0/sites?search=*

Interestingly this doesn't work in the beta version of the graph API (at this time).

This achieves what I wanted so I'm posting this as an answer, but it doesn't quite answer the question of how a search should be formatted so I'll leave this question open for somebody else to answer if they can.