0

I need to take a count of each group from Azure AD using Graph API. Can anyone tell me how to achieve it

Ramesh
  • 35
  • 1
  • 4

2 Answers2

4

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

0

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.

Allen Wu
  • 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
  • Thanks for your time to answer my query – Ramesh Nov 26 '19 at 07:50