I'm trying to use the Graph API to get information about user's permissions. I'm able to retrieve everything I want in a good format on the graph explorer using this request:
However I don't know how to translate the /microsoft.graph.group in a Graph API SDK request. This is what I have now:
await this._graphServiceClient.Users[userId].TransitiveMemberOf.Request().Select(this.GetQuery()).GetAsync();
Is there a way to specify I only want the groups as OdataType?
I know I could filter on this type once the request is done, but if I don't have to do this it is better.
CodePudding user response:
There is no support for OData casting in Graph API dotnet sdk but some inspiration how to append microsoft.graph.group
to request url can be found in msgraph-sdk-dotnet-contrib repository.
There is a WithODataCastMethod
which applies an OData cast filter to the returned collection.
Example of usage of that method
await this._graphServiceClient.Users[userId]
.TransitiveMemberOf
.WithODataCastMethod("microsoft.graph.group")
.Request()
.Select(this.GetQuery())
.GetAsync();