Nitin Rastogi
Nitin Rastogi

Reputation: 1456

Organization Hierarchy using Microsoft Graph

I am looking to work on Organization Chart and related pieces. In order to build the same, I am looking to leverage the Microsoft Graph for data retrieval.

Question 1

I don't see a direct endpoint that allows me to pull the entire hierarchy (upwards). So, is the only option available would require to write a recursive code to pull upwards hierarchy starting at a particular user i.e. get manager of current user, then get manager of manager and so on until you are done with hierarchy.

Question 2

Also, there are other options like Azure AD API. However, there is a general recommendation from MS on leveraging the MS Graph endpoint instead of specific product focused endpoints. Requesting for thoughts on the same.

Upvotes: 2

Views: 7382

Answers (2)

NaMo
NaMo

Reputation: 533

Up-

GET /me/manager
GET /users/{id | userPrincipalName}/manager

Down-

GET /me/directReports
GET /users/{id | userPrincipalName}/directReports

Documentation-

https://learn.microsoft.com/en-us/graph/api/user-list-manager?view=graph-rest-1.0&tabs=http https://learn.microsoft.com/en-us/graph/api/user-list-directreports?view=graph-rest-1.0&tabs=http

Test it out here.

Upvotes: 6

Dan Kershaw - MSFT
Dan Kershaw - MSFT

Reputation: 5838

Q1: Nope - we don't have this today. Please file a request for this on UserVoice and others can also vote for this feature.

Q2: Whatever is exposed by Azure AD is already exposed in Microsoft Graph with a few exceptions. As such, the recursive manager function doesn't exist there either. We'd like developers to use Microsoft Graph where possible. The future is Microsoft Graph, and if we built such a feature, that would be where we would expose it.

Hope this helps,

Upvotes: 4

Related Questions