使用 Microsoft Graph 通过查找 ID 获取 SharePoint 用户

Ask*_*ous 2 sharepoint sharepoint-api sharepoint-list microsoft-graph-api

我在 Microsoft Graph 中执行以下查询:

var results = await SPLists["<my-list-name>"]
                .Items
                .Request()
                .Expand("fields")
                .GetAsync(); 
Run Code Online (Sandbox Code Playgroud)

它获取我在 SharePoint 中拥有的列表的列表项。该列表中的一列的类型为“个人或组”。在 Microsoft Graph 的响应中,它返回如下所示的列数据(例如):

{
    "LookupId": 335,
    "LookupValue": "John Doe"
}
Run Code Online (Sandbox Code Playgroud)

我如何利用这些数据?如何355使用 Microsoft Graph 获取身份识别人员的完整个人资料?我需要返回者的电子邮件地址。如何使用 Microsoft Graph SDK 获取该信息?

Jer*_*rry 5

Look Id 335是名为“用户信息列表”的SharePoint隐藏列表中的Id,您可以使用以下请求获取列表guid:

https://graph.microsoft.com/v1.0/sites/site-id/lists?$filter=DisplayName eq 'User Information List'
Run Code Online (Sandbox Code Playgroud)

然后使用下面端点中的列表 GUID 来获取详细的电子邮件地址:

https://graph.microsoft.com/v1.0/sites/site-id/lists/UserInformationListId/items/335
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

这里有一个类似的线程供您参考:

如何从User字段LookupId获取用户