Filtering and Expanding Users

Vivian Escalante 21 Reputation points
2022-09-15T22:40:01.75+00:00

Hello,

Has anyone used $filter and $expand at the same time?

I’ve tried with top + select + filter + count and this works

 https://graph.microsoft.com/v1.0/users?$top=13&$select=id,givenName&$filter=endsWith(mail,'@hello.com')&$count=true  

Tried top + select + expand + count and this works as well

https://graph.microsoft.com/v1.0/users?$top=13&$select=id,givenName&$expand=manager($select=id,givenName)&$count=true  

But once I try both filter and expand it doesn’t work:

https://graph.microsoft.com/v1.0/users?$top=13&$select=id,givenName&$filter=endsWith(mail,'@hello.com')&$expand=manager($select=id,givenName)&$count=true  

241613-screen-shot-2022-09-15-at-33752-pm.png

Microsoft Security | Microsoft Entra | Microsoft Entra ID
Microsoft Security | Microsoft Graph
{count} votes

5 answers

Sort by: Most helpful
  1. Shivam Dhiman 6,081 Reputation points
    2022-09-16T03:58:55.577+00:00

    Hi @Vivian Escalante

    I am able to replicate same scenario. As per this Query Parameters documentation "$expand is not currently supported with advanced queries."
    (endsWith) operators on the $filter is considered as Advanced query that is why expand is not working in the above Graph API.

    As a workaround you can use
    https://graph.microsoft.com/v1.0/users?$count=true&$top=13&$select=id,givenName&$filter=startsWith(mail,'Alex')&$expand=manager($select=id,givenName) this Graph API endpoint. Please refer to the below sample screenshot.
    241716-expandstartwith.png

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote. If you have any further questions about this answer, please click Comment.

    0 comments No comments

  2. Vivian Escalante 21 Reputation points
    2022-09-16T18:03:58.347+00:00

    @ShivamDhiman-1582 Hello, thank you for the response. Unfortunately this isn't really a workaround for what we want to achieve. We want to only return those with emails ending with a specific domain.

    0 comments No comments

  3. Zehui Yao_MSFT 5,876 Reputation points
    2022-09-27T01:35:27.007+00:00

    Hi @Vivian Escalante , since this feature is presently not available, you can submit a feature request idea using this support link, which will be monitored by Microsoft team and make the enhancements to Microsoft Graph APIs. I will also upvote for you.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  4. Simone 0 Reputation points
    2023-02-20T08:08:36.65+00:00
    0 comments No comments

  5. Simone 0 Reputation points
    2023-02-20T11:00:57.6033333+00:00

    Hi @Shivam Dhiman , could you please see my previous answer? I forgot to tag you

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.