Unable to cast object of type 'Microsoft.Graph.GroupMembersCollectionWithReferencesPage' to type 'Microsoft.Graph.Group'

298 views Asked by At

Unable to cast object of type 'Microsoft.Graph.GroupMembersCollectionWithReferencesPage' to type 'Microsoft.Graph.Group'.

Please give me any solution , I got above error when I try to fetch azure group members by using Microsoft graph API. I used this namespace (using Group = Microsoft.Graph.Group;) var members = (Group)teamClient.Groups[itemmembers.Id].Members.Request().GetAsync().Result;

What i need to do to fix it , u need to configure my azure portal settings or i need to modify azure function code

1

There are 1 answers

0
Cornelius J. van Dyk On

It looks like you may be using a TeamClient object instead of a GraphServiceClient object. This is how to get it with a GraphServiceClient object:

GraphServiceClient graphClient = new GraphServiceClient(authProvider);
var members = await graphClient.Groups["{group-id}"].Members.Request()
    .GetAsync().GetAwaiter().GetResult();