Skip to main content

Notifications

Community site session details
Power Automate - Building Flows
Answered

Graph API Request to Filter Active Members and Groups

Like (2) ShareShare
ReportReport
Posted on 22 Aug 2024 14:55:49 by 11,205 Super User 2025 Season 1
I need to make a call to the Graph API to get the members of a group with an active account and also return other groups within the group. I am using the following filter:
https://graph.microsoft.com/v1.0/groups/@{variables('Group ID')}/members?$count=true&$select=mail&$filter=endsWith(mail,'@mycompany.com') and accountEnabled eq true&$top=999
  • Note, the above query has ConsistencyLevel: eventual in the headers.
  • This works, but does not return any of the groups as it appears groups do not use the accountEnabled flag.
  • I searched the web and asked Copilot how to modify the query to include groups.
  • Copilot said to add or isOf('microsoft.graph.group') to the filter, but when I do it returns the error: "message": "Operator: 'IsOf' is not supported."
  • In this reference I cannot find anything related to filtering for groups: Advanced query capabilities on Microsoft Entra ID objects - Microsoft Graph | Microsoft Learn
Does anyone know how I can modify the query to include groups?
 
Thank you,
David
  • Verified answer
    Expiscornovus Profile Picture
    31,732 Most Valuable Professional on 23 Aug 2024 at 09:48:27
    Graph API Request to Filter Active Members and Groups
    Afaik you can also use an $expand on members. That method does has some limitations but when you use an $expand it should also return details of the groups itself. Might be worth a shot?

    Btw, there are also a Transitivemembers method to retrieve users and groups of a group:

Helpful resources

Quick Links

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Leaderboard >