Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to get profile info using Sharepoint and Microsoft Graph api

When trying to GET mail url https://graph.microsoft.com/v1.0/me I keep getting responses like "mail:null".

The full response is as follows:

{
  "@odata.context": "https://graph.microsoft.com/v1.0/",
  "@odata.type": "#microsoft.graph.user",
  "@odata.id": "users/XXXXXXXXX",
  "businessPhones": ["XXXXXXXX"],
  "displayName": "XXXX XXXX",
  "givenName": "XXXX",
  "jobTitle": null,
  "mail": null,
  "mobilePhone": "XXXXXXXX",
  "officeLocation": null,
  "preferredLanguage": "en-US",
  "surname": "XXXXXXX",
  "userPrincipalName": "[email protected]",
  "id": "XXXXX-XXXXX-XXXXX"
}

Does anybody know why it won't return with the full profile info? I am using version 1.0.

like image 425
Gustavo Alfonso Avatar asked Nov 23 '15 16:11

Gustavo Alfonso


People also ask

How can I get user details from Microsoft Graph API?

You can access users through Microsoft Graph in two ways: By their ID, /users/{id} By using the /me alias for the signed-in user, which is the same as /users/{signed-in user's id}

How do I find my user ID for graph API?

You can get the user information for the signed-in user by replacing /users/{id | userPrincipalName} with /me .


1 Answers

When you query the user entity (or /me), Graph returns a default set of properties (the ones you see above). We're doing this because the user entity contains a truckload of properties, and we want to make sure we're somewhat efficient here (since there's cost to serialize and deserialize a bunch of properties over the wire). In order to get other properties (including SharePoint profile properties) that aren't in the default set, you need to use $select=propName1,propName2 in the querystring. To see the full list go here: https://graph.microsoft.io/docs/api-reference/v1.0/resources/user. We're also looking at introducing $select=* to get all properties too.

As for why mail and officeLocation aren't populated. The mail property is set under certain conditions (like the user is assigned a license that gives them a mailbox). OfficeLocation is null unless it is set for a user.

Hope this helps,

like image 129
Dan Kershaw - MSFT Avatar answered Sep 30 '22 12:09

Dan Kershaw - MSFT