5
votes

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.

1
If the email is not in mail because is an alternative email, I would like to be able to get it as well. I cannot find a way to make otherMails return because it appears in the newer API it is no longer an available field.Gustavo Alfonso

1 Answers

6
votes

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,