Is there anyway to get a list of Sharepoint Online sites equivalent to the Get-SPOsite cmdlet?
Yes, you can use the Search for Sites endpoint and pass a wildcard as your query. See example below:
https://graph.microsoft.com/v1.0/sites?search=*
This will return all sites in the tenant.
Related
When I use the Microsoft Graph API /sites?search=* endpoint, I get very old deleted sites returned. When I then try to access these sites I get a 404 error.
Note: Some of these sites are not in the SharePoint admin 'Deleted Sites' list either.
So my questions are:
Is this (returning deleted sites) expected?
Is there a way to exclude deleted sites from search results?
I work with SharePoint Online drives(document libraries) with Microsoft Graph API (/drives call). With this API I can download/upload files but cannot work with permissions.
That's not a problem - I can do it with SharePoint Online REST API (with calls _api/web/GetListByTitle('Title')/hasuniqueroleassignments).
The main problem here is matching drive from MS Graph API and a corresponding list from SharePoint REST API. For now I match by title but I have several examples, when name field in MS Graph API is equal to "OneDrive", but title in List entity is Shared Pictures.
My question is: is there any way to match more precisely entities from Graph API and SharePoint REST API?
Thank you.
The Drive Item object has a SharePointIds property that will provide the information necessary to call the SharePoint REST API.
https://learn.microsoft.com/en-us/graph/api/resources/sharepointids?view=graph-rest-1.0
Use List resource, you could get list id.
Then use id to call rest api.
/_api/web/Lists(guid'54ca94c0-364e-4201-8fe7-a4c804769009')/hasuniqueroleassignments
I am trying to get informations about user/mailbox type (regular, distribution list, shared mailbox, alias) using the Microsoft graph API. I tried using the /users endpoint but I see there is no field with such info. Is there any way of doing this?
https://learn.microsoft.com/en-us/graph/api/user-list?view=graph-rest-1.0&tabs=http
Thanks!
That information is only available from Exchange PowerShell (Get-Mailbox), which isn't yet available via Graph. You can get a list of groups (https://learn.microsoft.com/en-us/graph/api/group-list?view=graph-rest-1.0&tabs=http) and a list of users (https://learn.microsoft.com/en-us/graph/api/user-list?view=graph-rest-1.0&tabs=http). I don't know if that will work for your purposes.
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?
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
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
Is there a method to retrieve SharePoint Groups using Microsoft Graph?
I can get Azure Directory groups using https://graph.microsoft.com/v1.0/groups but what I'm looking for are SharePoint Groups.
I could get a SiteCollection using https://graph.microsoft.com/beta/sites/{id} but I couldn't seem to get the SharePoint Groups in site collection.
This is not very easily accessible in just the Microsoft Graph. If you had some access to the SharePoint API, you could get the GUID from the "User Information List" - which seems hidden from the Microsoft Graph at this time. That SharePoint API call would be
GET HTTP https://sometenant.sharepoint.com/_api/web/lists?$select=title,id&$filter=Title%20eq%20%27User%20Information%20List%27
Once you have that GUID for that list you could do the Graph call:
https://graph.microsoft.com/beta/sites/{site id}/lists/{list ID from the SharePoint API}/items
That will get you the full list of members, including groups. This is still a hack since the groups you'd have to filter by contentType/name eq 'SharePointGroup' - which seems buggy in Graph Explorer anyways. Trying to programmatically access that, would be difficult at this time.