Different Ways to Get SharePoint Site Collection using Microsoft Graph API


Microsoft Graph API has a single endpoint that allows us to access any data across the Office 365 environment using different parameters. This post explores the different ways of retrieving the Site Collection using MS Graph API from Microsoft Graph Explorer.
  •  Navigate to Microsoft Graph Explorer
  • Select the GET method from Request drop down
  • Select the version as v1.0 or beta
  • Enter the API endpoint to the request textbox and then click the Run Query button to run the Graph request.
  • Use the Permissions section to agree the scopes required for accessing the API.

To read site collection-related information, we must agree to the Site.Read.All permission scope 

We can access the site collection using three different ways in Microsoft Graph API:

  • By using the root
  • By using the Site ID
  • By using the Site server relative URL.
  • By using the Group ID

Get SharePoint site collection by using ‘root’ 

The root parameter next to the sites denotes the default and top-level site collection. 


Get SharePoint site collection using the Site ID 

If we have the unique ID of the site collection, we can retrieve it by specifying site ID next to the sites.   

https:// graph.microsoft.com/v1.0/sites/<siteid>


https:// graph.microsoft.com/v1.0/sites/298ada92-042b-4bf3-ae87-3b207baf17dc

Get SharePoint site collection by using the server relative URL

https://graph.microsoft.com/v1.0/sites/<host>:<server relative url>



Get SharePoint site collection using the Group ID

If the SharePoint site collection is created based on an Office 365 group, we can use the below endpoint to retrieve the top-level site.

https:// graph.microsoft.com/v1.0/groups/<group-id>/sites/root


https:// graph.microsoft.com/v1.0/groups/ 298ada92-042b-4bf3-ae87-3b207baf17dc/sites/root