Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

How to lookup all sites with the Microsoft Graph API

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://learn.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://learn.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

Answer*

Cancel
1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center. Commented May 3, 2024 at 19:04