user989988
user989988

Reputation: 3736

Get Members from Delta Query on Groups

How do I return only Members from the delta API for group (https://learn.microsoft.com/en-us/graph/delta-query-overview?tabs=http)

Adding .Members & .Select() are not supported

enter image description here

await _graphServiceClient
                                    .Groups
                                    .Members
                                    .Delta()
                                    .Request()
                                    .Filter($"id  eq '{groupId}'")                                  
                                    .GetAsync();

On trying this:

        var queryOptions = new List<QueryOption>()
        {
            new QueryOption("select", "members")
        };
       
            await _graphServiceClient
                                .Groups                                    
                                .Delta()
                                .Request(queryOptions)
                                .Filter($"id  eq '{groupId}'")
                                .GetAsync();

I see this error:

Message: Unrecognized query argument specified: 'select'. What am I missing?

Upvotes: 0

Views: 559

Answers (2)

user2250152
user2250152

Reputation: 20625

Use Select method after Request.

var delta = await _graphServiceClient.Groups
    .Delta()
    .Request()
    .Select("members")
    .Filter($"id eq '{groupId}'")
    .GetAsync();

in your example with QueryOption you are missing $ before select

var queryOptions = new List<QueryOption>()
{
    new QueryOption("$select", "members")
};
   
await _graphServiceClient
                    .Groups                                    
                    .Delta()
                    .Request(queryOptions)
                    .Filter($"id eq '{groupId}'")
                    .GetAsync();

Upvotes: 1

vicky kumar
vicky kumar

Reputation: 738

You can try with below code

var user = await graphClient.Groups["{group-id}"].Members .Request( queryOptions ) .Header("ConsistencyLevel","eventual") .Select("displayname,id") .GetAsync();

You can refer docs for more info - https://learn.microsoft.com/en-us/graph/api/group-list-members?view=graph-rest-beta&tabs=csharp#example-4-use-search-and-odata-cast-to-get-user-membership-in-groups-with-display-names-that-contain-the-letters-pr-including-a-count-of-returned-objects

Hope this helps

Thanks

Upvotes: 0

Related Questions