8

I was sure about after reading Microsoft document that I can filter the group members using OData Query Parameters because https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/group_list_members

Request GET URL - https://graph.microsoft.com/v1.0/groups/{groupId}/members?filter= startswith(givenname,'V')

In above URL groupId is used from https://graph.microsoft.com/v1.0/groups

but when I try to get the result using Graph Explorer (https://developer.microsoft.com/en-us/graph/graph-explorer) using my work account login, it's not working.

Also I have tried to use this in SDK (I have implemented graph API in my code using Microsoft graph API SDK) and still got same error.

And gives below error -

{ "error": { "code": "Request_UnsupportedQuery", "message": "The specified filter to the reference property query is currently not supported.", "innerError": { "request-id": "96f3ffef-56f5-42e3-82f2-64813106b729", "date": "2018-02-13T10:59:39" } } }

Is this because "members" is not a resource type ? so it does not have properties and so we can not filter this result ?

If so then is there any other way we can get filtered group members ?

Also posted issue on Github - https://github.com/microsoftgraph/microsoft-graph-docs/issues/2239

4
  • I believe it is because /members returns a list of directoryObjects. Even though the user resource inherits from directoryObject, you can't filter on givenName here. You would have to do client-side filtering to search for specific members. Commented Feb 13, 2018 at 16:18
  • Per my testing, both Microsoft graph and Azure AD graph could not support the filter query against group members as you mentioned. You may retrieve all the members under a specific group and filter them in your client as RasmusW commented. Or you could add your feature request to Microsoft Graph team. Commented Feb 14, 2018 at 7:13
  • 1
    @BruceChen thanks. Microsoft documentation should be corrected then that we can not filter group members. Commented Feb 14, 2018 at 7:23
  • 1
    I've created a UserVoice suggestion for this: officespdev.uservoice.com/forums/… Commented Oct 4, 2018 at 12:27

3 Answers 3

4

Add ConsistencyLevel: eventual to Your request header (should work for v1.0 and beta as well)

Sign up to request clarification or add additional context in comments.

2 Comments

As of now, ConsistencyLevel header and $count query parameter are required for this filter to work. See here.
//testing the filter query here // Get groups user is a member of // GET /me/memberOf var myfilteredUserGroups = await _graphClient.Me.MemberOf .Request(queryOptions) .Header("ConsistencyLevel", "eventual") .Filter("startswith(displayName, 'sa')") .Select("displayName,groupTypes,id") .Top(GraphConstants.PageSize) .GetAsync();
0

Filtering of group members is now available as a beta API.

GET https://graph.microsoft.com/beta/groups/{id}/members?$count=true&$filter=startswith(displayName, 'a')

Comments

0

Here's how you would impelment it in code

            //testing the filter query here 
            // Get groups user is a member of
            // GET /me/memberOf
            var myfilteredUserGroups = await _graphClient.Me.MemberOf
                .Request(queryOptions)
                .Header("ConsistencyLevel", "eventual")
                .Filter("startswith(displayName, 'sa')")
                .Select("displayName,groupTypes,id")
                .Top(GraphConstants.PageSize)
                .GetAsync();

            // This method casts the returned DirectoryObjects
            // as Group object, and filters out any non-Group objects
            model.MyFilteredGroups = await GetAllPagesAsType<Group>(
                _graphClient, myfilteredUserGroups);

            return View(model);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.