Tracy
Tracy

Reputation: 670

MS Graph: How To Distinguish Teams-Enabled M365 Groups Using GraphClient?

The MS Graph rest API surfaces a resourceProvisioningOptions attribute to indicate whether a MS365 group is also a Team (see below). However, those values do not appear to be available in the GraphServiceClient.

I found this post, and used the sites endpoint to get the associated SharePoint URL for an M365 group. But some M365 groups have SharePoint sites and are not Teams.

The only other option I found was to use the teams endpoint and catch the exception when no team is found for the group ID. But then I still have to do the additional sites endpoint query to get the SharePoint URL.

Does anyone know of another/better way to distinguish between Team/non-Team M365 groups when using the GraphServiceClient?

enter image description here

Upvotes: 2

Views: 914

Answers (2)

Michael Mainer
Michael Mainer

Reputation: 3475

I'd like to pile on to the helpful post by Baker_Kong.

This functionality is available in both the beta and v1.0 endpoints. It is not described in the v1.0 metadata (which we use to generate the model) and that is why you aren't seeing this in the object model. Until this is resolved, you could use the beta client or:

// Get only groups that have teams.
var groupsThatHaveTeams = await client.Groups.Request().Filter("resourceProvisioningOptions/Any(x:x eq 'Team')").GetAsync()

// When the metadata is fixed, each group will have a ResourceProvisioningOptions property that you can inspect for the 'Team' value.
// Until then, you'd need to look at the Group.AdditionalData dictionary for the resourceProvisioningOptions key and check if it has the 'Team' value.
var groupsThatMayHaveTeams = await client.Groups.Request().Select("id,resourceProvisioningOptions").GetAsync();

cross posted from https://github.com/microsoftgraph/msgraph-sdk-serviceissues/issues/44#issuecomment-752775347

Upvotes: 3

Baker_Kong
Baker_Kong

Reputation: 1889

@Tracy,

I have a test the SDK in a console app, I believe this property is under the group entity:

enter image description here

or you can add select option to omit the returned properties:

graphClient.Groups.Request().Select("id,resourceProvisioningOptions").GetAsync().Result;

BR

Upvotes: 2

Related Questions