I need to take a count of each group from Azure AD using Graph API. Can anyone tell me how to achieve it
2 Answers
I also faced the similar issue. When I ran the end point mentioned in https://learn.microsoft.com/en-us/graph/api/group-list-members?view=graph-rest-1.0&tabs=http#example-2-get-only-a-count-of-all-membership I got "$count is not currently supported."
However, if you notice the documentation clearly, it asks us to send in the ConsistencyLevel as eventual in the REST header. I got the correct response when I sent the header along with the call:
GET https://graph.microsoft.com/v1.0/groups/{id}/members/$count ConsistencyLevel: eventual

- 41
- 4
-
Another helpful example here: https://www.koskila.net/graph-api-throws-count-is-not-currently-supported-when-you-know-its-supported/ – Maxime Pacary Nov 16 '21 at 13:42
-
What a lifesaver!! – mvreijn Dec 16 '21 at 10:19
There is currently no Microsoft Graph endpoint to get the number of users.
You could list members by using:
GET https://graph.microsoft.com/v1.0/groups/{id}/members
And then handle the count of the members in your code.
See the reference here. Try it quickly with Microsoft Graph Explorer.

- 15,529
- 1
- 9
- 20
-
There is restriction for listing members as well. For each call it can list only 2500 member's. so if have more 50k memebers, then counting will be difficult – Ramesh Nov 25 '19 at 16:38
-
I'm not sure how you get the result. Based on my test, `GET /groups/{id}/members` will list more than 2500 members with the `@odata.nextLink` property. You can retrieve the next page of results by sending the URL value of the @odata.nextLink property to Microsoft Graph. See details here: https://learn.microsoft.com/en-us/graph/paging. If you consider @odata.nextLink as another call, I have to agree that this is by-design of Microsoft Graph. As I mentioned at the beginning, it doesn't support to get the numbers directly. – Allen Wu Nov 26 '19 at 04:16
-