Microsoft Graph API: Get Users manager chain

Iron Contributor

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.

7 Replies

The latter, multiple calls for each manager up the chain.

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
This 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.

@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!

@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?

@kumarrag I'm not aware of any changes, and this still seems to work for me. Have you checked to make sure there's indeed a manager attribute listed for the user itself?

For 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)&$...), if I want to get list of them with chain (like: https://graph.microsoft.com/v1.0/users?$expand=manager($levels=max;$select=userPrincipalName)&$selec...), it does not work, it returns just direct manager.