首页 > 解决方案 > 使用 Graph API 如何编写 Sharepoint“个人或组”字段?

问题描述

我有一个 Sharepoint Online 列表,其中包含“个人或组”类型的列。我想使用 Microsoft Graph API(最终来自 Teams 机器人)为此类列创建一个新条目。

我的问题是这样的列包含一个查找值,我不知道如何获得这个数字。我可以从 Graph(/me 或 /users)成功获取用户对象,但返回的对象有一个完全不同的 id。如何将此链接到 Sharepoint Online 所需的内容?

示例:SG_ResponsibleGraph 返回的类型为“Person or Group”的 Sharepoint 列(注意它报告为SG_ResponsibleLookupId):

      "fields": {
                "@odata.etag": "\"e2977d91-fd6d-4141-8bc6-897f5bbe9840,1\"",
                "Title": "Test 2",
                "SG_ResponsibleLookupId": "12",
                "SG_Description": "This is a Test",
       ...

来自的相应用户/users

        {
            "businessPhones": [],
            "displayName": "John Doe",
            "givenName": null,
            "jobTitle": null,
            "mail": null,
            "mobilePhone": null,
            "officeLocation": null,
            "preferredLanguage": null,
            "surname": null,
            "userPrincipalName": "john@example.com",
            "id": "76a3b5b7-768b-4dde-ba13-6d471aa2c7fd"
        },

那么如何确定这个用户是 Sharepoint 的用户 #12?

标签: microsoft-graph-apisharepoint-online

解决方案


SharePoint REST API 应该能够为您提供您正在工作的网站集中的用户 ID。

用相应的值替换这些值。

SharePointWebURL/_api/web/siteusers?$filter=Email eq 'UserEmail'&$select=Id

然后,您应该能够获取可用于验证查找字段值的用户ID 。


推荐阅读