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.
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}
You can get the user information for the signed-in user by replacing /users/{id | userPrincipalName} with /me .
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,
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With