尝试使用 Sharepoint 和 Microsoft Graph api 获取个人资料信息 [英] Trying to get profile info using Sharepoint and Microsoft Graph api

查看:27
本文介绍了尝试使用 Sharepoint 和 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆