Alternative to advanced queries in Microsoft Graph API

Toky SOLOFONIRINA 5 Reputation points

Hello everyone,

I am trying to import users from Entra ID using the Graph API.

The import should be done by company, as there are multiple companies in the Tenant.

A request like this is working fine (I have tried) :$count=true&$filter=endsWith(mail,'domain.xx')&$orderBy=userPrincipalName&$select=companyName,employeeId,mailNickname,department,id,displayName,jobTitle,mobilePhone,surname,givenName,userPrincipalName,mail

This is using advanced query as I could read from the documentation.

Now the problem occurs when I try to get the users with their respective Manager, I have tried something like :$count=true&$filter=endsWith(mail,'domain.xx')&$orderBy=userPrincipalName&$select=companyName,employeeId,mailNickname,department,id,displayName,jobTitle,mobilePhone,surname,givenName,userPrincipalName,mail&$expand=manager

I tried getting the managers with the expand Query Parameter, and got the error :

    "error": {
        "code": "Request_UnsupportedQuery",
        "message": "Operator 'endsWith' is not supported because the required parameters might be missing. Try adding $count=true query parameter and ConsistencyLevel:eventual header. Refer to for more information",
        "innerError": {
            "date": "2024-03-19T07:03:31",
            "request-id": "d7cb8a62-6cd2-45d1-a2aa-5624d32f4fe5",
            "client-request-id": "fafdf0c3-728a-7d96-bb06-3a1dfdc2a4f3"

After a quick research, I found out that the expand query parameter is not working for advanced queries yet, as per :


So I am asking if there is an alternative to expand for me to get all users with their manager. Our should I get all users and after do a second request to get their manager. Any help or clarification is really appreciated.

PS : The goal is to import users info and their manager into the app database.

PS2: sorry for my bad english ...

Thank you in advanced.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,526 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,395 questions
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. Vasil Michev 94,911 Reputation points MVP

    The alternative would be to get the full set of users with the manager info included, then filter the list client-side.