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

冷暖自知 提交于 2020-01-24 19:52:09

问题


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 even if I put a correct ID value.


回答1:


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"]
}


来源:https://stackoverflow.com/questions/47010078/how-to-update-a-lookup-field-and-a-user-field-in-sharepoint-with-microsoft-graph

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!