'Microsoft Graph API, Get SharePoint Site Admin/Members

Trying to use Microsoft's Graph API to iterate through Sharepoint sites, in order to find and remove a user's access to sites when they go out of the country.

Graph / Sharepoint API documentation: https://docs.microsoft.com/en-us/graph/api/resources/site?view=graph-rest-1.0

I get a list of all sites using the Get Sites endpoint:

https://graph.microsoft.com/v1.0/sites

I then filter out personal / OneDrive sites, and try to use the List Site Permissions endpoint to try to get admins/members: https://docs.microsoft.com/en-us/graph/api/site-list-permissions?view=graph-rest-beta&tabs=http

Unfortunately, I get an empty value array in response for all sites:

{'@odata.context': "https://graph.microsoft.com/v1.0/$metadata#sites('<domain>.sharepoint.com%asdfasdgsdf-ca8f-4ec1-bb3e-sdfsdfsdgsdf%2Cbed949c3-3f83-47c2-a263-sdfsdfsdgasdf')/permissions", 'value': []}

I know that the query is fine, because if I change it to instead hit the Site Lists endpoint, I get a response which includes various values:

{'@odata.context': "https://graph.microsoft.com/v1.0/$metadata#sites('<domain>.sharepoint.com%sdfsdfsdgsd-7dce-4564-9de8-eb2dfc02eb86%sdfsdgsdfsdf-ab8c-464f-a77d-sdfsdfsdgsdg')/lists", 'value': [{'@odata.etag': '"sfwsdgsdg-aff1-4295-8443-sdfsdgasdf,7"', 'createdDateTime': '2020-08-26T16:17:41Z', 'description': 'This library contains items that have been modified or deleted but must remain available due to eDiscovery holds. Items cannot be modified...
...

So, the Site ID I am passing to the permissions request must be correct. Is this the wrong endpoint then? Or, is this functionality missing from the Graph API, and my only solution is via the SP Powershell module?

I have tried with both the v1.0 and beta vesions of the API.

Thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source