如何使用Microsoft Graph更新SharePoint中的查找字段和用户字段?
问题描述:
我正在寻找一种如何使用Microsoft graph更新查找字段和用户字段的方法? 我可以阅读该项目,但是即使输入正确的ID值,也找不到创建或更新此类字段的方法.
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.
答
现在,它支持通过Microsoft Graph API更新查找字段.
Nowadays it is supported to update lookup fields via Microsoft Graph API.
让我们说有一个名为Category
的字段,然后根据查找字段是以单值还是多值表示,下面的示例演示了如何设置查找字段值.
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.
用于单值字段:
Url: https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items/{item-id}/fields
Method: PATCH
Body: {
"CategoryLookupId": "1"
}
其中
-
field name
以以下格式提供:{field-name}LookupId
-
field value
对应于查找ID,并以字符串形式提供
-
field name
is provided in the following format:{field-name}LookupId
-
field value
corresponds to lookup id and provided as a string
用于多值字段
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"]
}