问题
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 nameis provided in the following format:{field-name}LookupIdfield valuecorresponds 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