nam
nam

Reputation: 23859

How to use Microsoft Graph API to display manager of a user resource type in Azure AD

Question: Using Microsoft Graph how do we display the manager of a user? For example, using Microsoft Graph Explorer you can get a signed-in user profile info by calling https://graph.microsoft.com/v1.0/me. But this call does not return all the fields - specifically not the manager field.

I tried https://graph.microsoft.com/v1.0/me?$select=manager but it still did not return manager.

In the Relationships section of user resource type you see a manager field for a user's manager. And the Json representation of that Relationships shows manager field as follows:

"manager": { "@odata.type": "microsoft.graph.directoryObject" }

But I am not sure how do we use it to get he manager of a user.

UPDATE:

Following is a screenshot of just a portion of result from the query from the user @CarlShao. In fact it is returning tons of attributes for manager object. But I'm showing just current screen of my laptop: enter image description here

enter image description here

Upvotes: 1

Views: 4979

Answers (1)

Carl Zhao
Carl Zhao

Reputation: 9539

If you need to expand the user's organizational relationship, you should use the $expand parameter, which supports expanding the user's directReports, manager and memberOf relationships.

GET https://graph.microsoft.com/v1.0/me?$expand=manager

reference:list manager and expand parameter.


Update:

You can specify $select inside $expand to select the individual manager's properties: $expand=manager($levels=max;$select=displayName)

https://graph.microsoft.com/v1.0/me?$expand=manager($levels=max;$select=displayName)&$count=true

Don't forget to add request header: ConsistencyLevel=eventual

enter image description here

Upvotes: 7

Related Questions