Forum Discussion
Gurdev Singh
Jul 01, 2019Iron Contributor
Microsoft Graph API: Get Users manager chain
Is there a way to get user's manager chain using Graph API, all the way to company CEO? or we'll have to make multiple calls for each manager.
VasilMichev
Jul 01, 2019MVP
The latter, multiple calls for each manager up the chain.
SamueleFurnari
Jun 30, 2021Copper Contributor
is the answer still valid? In the official docs (https://docs.microsoft.com/en-us/graph/api/user-list-manager?view=graph-rest-1.0) I read that the graph API exhibits an endpoint to get all manager chain but I can't feagure out how to use it... I tried Graph explorer and C# script but the result returns always the first level manager. I don't know if the endpoint does not works or if the problem is in my app permissions (as for now the app has Directory.ReadWrite.All and User.ReadWrite.All)
Thanks
Thanks
- pvanberloJul 01, 2021MCTThis actually works, however, when getting the chain of managers, please add the "consistencyLevel: eventual" header to the request, otherwise it will only return the direct manager.
- kumarragOct 08, 2021Former Employee
pvanberlo I have added this header in Graph Explorer as you have suggested, yet I am getting just my immediate manager. has anything changed since your last answer?
- Radoslav ŠopoňJul 19, 2022Copper ContributorFor me it works just if I query 1 specific user (like: https://graph.microsoft.com/v1.0/users/{id}?$expand=manager($levels=max;$select=userPrincipalName)&$select=userPrincipalName&$count=true), if I want to get list of them with chain (like: https://graph.microsoft.com/v1.0/users?$expand=manager($levels=max;$select=userPrincipalName)&$select=userPrincipalName&$count=true), it does not work, it returns just direct manager.
- SamueleFurnariJul 01, 2021Copper Contributor
pvanberlo Thank you! Yesterday, just five minutes later the post on tech community, I opened a case to Microsoft... the customer service responded quikly and asked me to set the header...
I have seen the documentation so many times but I have not noticed the header 🙂
Thanks to the header from Graph explorer works well, now I need to get it to works with the .NET SDK.
Thanks again!