The alternative would be to get the full set of users with the manager info included, then filter the list client-side.
Alternative to advanced queries in Microsoft Graph API
![](https://techprofile.blob.core.windows.net/images/K0wuAEMTIkGT9ICsarjiPA.png?8DC3C8)
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) :
https://graph.microsoft.com/v1.0/users?$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 :
https://graph.microsoft.com/v1.0/users?$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 https://aka.ms/graph-docs/advanced-queries 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.