The following forum(s) are migrating to a new home on Microsoft Q&A (Preview): Azure Active Directory!

Ask new questions on Microsoft Q&A (Preview).
Interact with existing posts until December 13, 2019, after which content will be closed to all new and existing posts.

Learn More

 none
Microsoft Graph API Get ALL members from a supplied group RRS feed

  • Question

  • Hi

    I am trying to pull all the users for a given group.  the below code works to a point except that the group in question has over 100 users.  The results from below has 100 users which I understand is the max as set up.  I need the list for all the users, not just the top 100.  I see an Azure Active Directory suggestion online to use a "-all" flag but I cannot seem to find in the documentation an example of how to pull all the users and any help would be appreciated. Thank you.

    *Note 

    RestURL = "https://graph.microsoft.com"

    RestVersion = "v1.0"

    groupId = [passed guid]

    string URL = $"{Settings.RestURL}{Settings.RestVersion}/groups/{groupId}/members";

                  

                    HttpResponseMessage response = await client.GetAsync(URL);

                    if (response != null)
                    {
                        if (response.IsSuccessStatusCode)
                        {
                            string r = await response.Content.ReadAsStringAsync();
                            UserFilter filterResults = Newtonsoft.Json.JsonConvert.DeserializeObject <UserFilter>(r);
                            return filterResults.value;
                            
                        }
                        else
                        {
                            ErrorText = $"Error:  Status({response.StatusCode}).  Reason: {response.ReasonPhrase}";
                            return users;
                        }
                    }
                    else
                    {
                        ErrorText = "Null object response (Get Group).";
                        return users;
                    }

    Wednesday, June 13, 2018 2:19 PM

Answers

  • This is a limitation in the $expand parameter.

    If you want all of the groups, retrieve the members attribute and following the oData.NextLink if its present to page through the results.  There are several group related functions described at the following link:
    https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/groups-operations

    There are functions that can be used for group transitivity as well, just follow the navigation links generally located on the right of the above link.

     

    If this answer was helpful, click “Mark as Answer” or Up-Vote. To provide additional feedback on your forum experience, click here

    • Marked as answer by Cheesebread Wednesday, June 13, 2018 7:34 PM
    Wednesday, June 13, 2018 5:39 PM
    Moderator