0
votes

I have a Sharepoint Online list with a column of type "Person or Group". I want to make a new entry for such a column using the Microsoft Graph API (eventually from a Teams bot).

My problem is that such a column holds a lookup value into something and I don't know how to get this number. I can successfully get a user object from Graph (/me or /users) but the object returned has an id which is something completely different. How do I link this to what Sharepoint Online requires?

Example: Sharepoint column SG_Responsible of type "Person or Group" as returned by Graph (note it is reported as SG_ResponsibleLookupId):

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

The corresponding user from /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"
        },

So how to figure out that this user is user #12 for Sharepoint?

2

2 Answers

0
votes

User ID is site collection specific, you could get by SharePoint REST api, while no graph api for this based on my testing.

_api/web/siteusers

Checked this workaround while not working.

enter image description here

0
votes

SharePoint REST API should be able to give you the user id in the site collection you are working.

Replace the values with corresponding values.

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

Then you should be able to get the user Id that you would be able to use to validate lookup field value.