How to update a Lookup field and a user field in SharePoint with Microsoft Graph?

前端 未结 1 355
离开以前
离开以前 2021-01-22 11:26

I\'m looking for a way how to update a lookup field and a user field with Microsoft graph ? I can read the item, but I don\'t find a way to create or update this kind of field e

1条回答
  •  没有蜡笔的小新
    2021-01-22 12:06

    Nowadays it is supported to update lookup fields via Microsoft Graph API.

    Lets say there is a field named Category, then depending whether lookup field is represented as single or multi valued, the following examples demonstrate how to set lookup field value.

    for single-valued field:

    Url: https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items/{item-id}/fields    
    Method: PATCH 
    Body: {
      "CategoryLookupId": "1"
    }
    

    where

    • field name is provided in the following format: {field-name}LookupId
    • field value corresponds to lookup id and provided as a string

    for multi-valued field

    Url: https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items/{item-id}/fields    
    Method: PATCH 
    {
        "CategoryLookupId@odata.type": "Collection(Edm.String)",
        "CategoryLookupId":["1","2"]
    }
    

    0 讨论(0)
提交回复
热议问题