Thomas Harris
Thomas Harris

Reputation: 603

Are all sites a subsite of the root site in Microsoft Graph?

I am attempting to retrieve all SharePoint Sites via the Microsoft Graph REST API

Looking at the Site resource, I can see there are methods to get a root site, to get subsites, but also, to get sites by group.

Are all SharePoint sites, including group sites able to be found as subsites of the root site? Or do I need to retrieve every group and enumerate those too?

Upvotes: 0

Views: 877

Answers (2)

Vadim Gremyachev
Vadim Gremyachev

Reputation: 59358

To retrieve all the sites across tenant Search for sites endpoint could be utilized, for example:

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

To retrieve only group sites indeed, it appears the only supported approach would be to:

  • list all the groups, for example: GET https://graph.microsoft.com/v1.0/groups?$filter=groupTypes/any(c:c+eq+'Unified')&$select=id
  • and enumerate every group to retrieve group site: GET https://graph.microsoft.com/v1.0/groups/{group-id}/sites/root

Upvotes: 5

Paul Schaeflein
Paul Schaeflein

Reputation: 627

No. The organization root is a sibling to group sites.

The API does have a basic search capability, if that helps. https://learn.microsoft.com/en-us/graph/api/site-search?view=graph-rest-1.0

Upvotes: 1

Related Questions