简体   繁体   中英

Get list of members of type GROUP from Microsoft graph

I have the following code to get members of ONLY 'Group' type from a group using Microsoft Graph:

   
    var queryOptions = new List<QueryOption>() 
    { 
       new QueryOption("$count", "true") 
    }; 
    var r = await  _graphServiceClient.Groups["id"].TransitiveMembers["microsoft.graph.group"].Request(queryOptions).Header("ConsistencyLevel", "eventual").GetAsync(); 
    r.AdditionalData.TryGetValue("@odata.count", out object count); 
    r.AdditionalData.TryGetValue("value", out object value);

how do I get the list of groups from value object ?

Update :

There was some info missing from your question and i saw your updated question , and understand that you want list of groups from value object. you can achieve this by iterating the list of group and add to different array, please check the image below , similar question - https://docs.microsoft.com/en-us/answers/questions/288982/converting-from-api-to-sdk-c-unable-to-query-micro.html

GraphServiceClient graphClient = new GraphServiceClient( authProvider );

    var group = await graphClient.Groups["id"].MemberOf
        .Request()
        .Header("ConsistencyLevel","eventual")
        .GetAsync();

Ref doc- https://docs.microsoft.com/en-us/graph/api/group-list-members?view=graph-rest-1.0&tabs=csharp#example

在此处输入图像描述

hope this will help .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM