Microsoft Graph API has a single endpoint, which allow us to access any data across Office 365 environment by 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 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 Site.Read.All permission scope
We can access the site collection using three different ways in Microsoft Graph API,
- By using root
- By using Site ID
- By using Site server relative URL.
- By using Group ID
Get SharePoint site collection by using ‘root’
root parameter next to the sites, denotes the default and top level site collection
Get SharePoint site collection by using Site ID
If we have the unique id of the site collection, we can retrieve it by specifying site id next to sites,
Get SharePoint site collection by using server relative url
https://graph.microsoft.com/v1.0/sites/<host>:<server relative url>
Get SharePoint site collection using Group ID
If the SharePoint site collection is created based on Office 365 group, we can use the below endpoint to retrieve the top level site.
https:// graph.microsoft.com/v1.0/groups/ 298ada92-042b-4bf3-ae87-3b207baf17dc/sites/root
March 21, 2020 at 1:53 PM
Looks like https://graph.microsoft.com/v1.0/sites/ktsdemo.sharepoint.com:/sites/demos
not working and it is saying Malformed ID. Could you please confirm this works?