尝试使用Sharepoint和Microsoft Graph API获取配置文件信息 [英] Trying to get profile info using Sharepoint and Microsoft Graph api
问题描述
当尝试获取邮件URL https://graph.microsoft.com/v1.0/me
时,我不断收到类似"mail:null"
的响应.
When trying to GET mail url https://graph.microsoft.com/v1.0/me
I keep getting responses like "mail:null"
.
完整答复如下:
{
"@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": "XXXXXXX@XXXXX.onmicrosoft.com",
"id": "XXXXX-XXXXX-XXXXX"
}
有人知道为什么不会返回完整的个人资料信息吗? 我正在使用1.0版.
Does anybody know why it won't return with the full profile info? I am using version 1.0.
推荐答案
查询用户实体(或/me)时,Graph返回默认属性集(如上所示).之所以这样做,是因为用户实体包含大量的属性,并且我们想确保此处的效率(由于在网络上序列化和反序列化一系列属性会产生成本).为了获取默认集合中没有的其他属性(包括SharePoint配置文件属性),您需要在查询字符串中使用$ select = propName1 , propName2 .要查看完整列表,请点击此处: https://graph.microsoft .io/docs/api-reference/v1.0/resources/user . 我们也在考虑引入$ select = *来获取所有属性.
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.
关于为什么不填充mail和officeLocation的原因. mail 属性是在某些条件下设置的(例如,为用户分配了向他们提供邮箱的许可证).除非为用户设置了 OfficeLocation 为null.
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.
希望这会有所帮助,
这篇关于尝试使用Sharepoint和Microsoft Graph API获取配置文件信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!