How to update sharepoint list lookup column with Graph API

spuser02 21 Reputation points
2021-11-21T02:33:03.99+00:00

With graph api, I can update text column in sharepoint list successfully. But how can I update lookup column with graph api? Can anybody provide an example?

Any help would be greatly appreciated.

Microsoft 365 and Office SharePoint Development
0 comments No comments
{count} votes

Accepted answer
  1. MichaelHan-MSFT 18,126 Reputation points
    2021-11-22T01:52:00.98+00:00

    Hi @spuser02 ,

    Assume that the look up field is named Test, then you could update the column value like this:

    PATCH https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items/{item-id}/fields  
    Content-Type: application/json  
      
    {  
        "TestLookupId": "5"  
    }  
    

    In the body, the column name is in the following format: {fieldInternalName}LookupId . The value correspondes to lookup id in your parent list.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.