How can we get non-MS365 groups from Graph API?

Ivan Tioh 91 Reputation points
2022-03-14T10:00:58.45+00:00

From this MS documentation, I'm able to get expected MS365 groups with this API: GET https://graph.microsoft.com/v1.0/groups?$filter=groupTypes/any(c:c+eq+'Unified').

However, I'm trying to get the reverse of it, i.e. using the same list groups Graph API to get non-MS365 groups. I've tried the following but to no avail:

  1. https://graph.microsoft.com/v1.0/groups?$filter=groupTypes/all(c:c ne 'Unified') -> Error message: Filter not supported.
  2. https://graph.microsoft.com/v1.0/groups?$filter=(groupTypes/any(c:c eq 'Unified')) eq false -> Error message: Invalid expression caused by operator 'EqualsMatch'.
  3. https://graph.microsoft.com/v1.0/groups?$filter=not groupTypes/any(c:c eq 'Unified') -> Error message: Unsupported Query.

Is there a mistake in my OData expression above? Or is this a limitation that list groups Graph API has at the moment?

Thanks in advance.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,824 questions
0 comments No comments
{count} votes

Accepted answer
  1. Srinivasa Rao Darna 6,696 Reputation points Microsoft Vendor
    2022-03-14T10:34:19.947+00:00

    Hi @Ivan Tioh ,

    I am able to successfully get non Unified groups with below API, add $count=true query parameter as well. Passing this in API call is a requirement to make aad advanced queries for more details refer to this documentation aad-advanced-queries.

    GET /groups?$filter=NOT(groupTypes/any(s:s eq 'Unified'))&$count=true  
    ConsistencyLevel: eventual  
    

    The $filter operator requires advanced query parameters, which are:

    • ConsistencyLevel=eventual header
    • $count=true query string

    Not including these will result in error Request_UnsupportedQuery

    Example from documentation: List dynamic security groups

    Hope this helps.
    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful