Issue Updating Multi-Value Lookup Field in SharePoint List Item Using Microsoft Graph API
Hello Everyone!
I'm encountering an issue when trying to update a multi-value lookup field in a SharePoint list item using the @microsoft/microsoft-graph-client library. My code successfully updates fields of type string and number, but I’m facing problems with a field of type array (multi-value lookup).
The field in question is called users, which references multiple IDs from another SharePoint list. Below is the field’s metadata:
{
"columnGroup": "Custom Columns",
"description": "",
"displayName": "users",
"enforceUniqueValues": false,
"hidden": false,
"id": "xxxxxx",
"indexed": false,
"name": "users",
"readOnly": false,
"required": false,
"lookup": {
"allowMultipleValues": true,
"allowUnlimitedLength": false,
"columnName": "ID",
"listId": "xxxxxxx"
}
}
Here’s the relevant code I’m using to update the list item:
const res = await client
.api(`/sites/${siteID}/lists/${listId}/items/${itemId}`)
.expand("fields")
.patch({
fields: updateData,
});
The update works fine when I set a single value for the users field. However, when I attempt to update it with multiple IDs (e.g., [9, 12]), the request completes without errors, but the field does not update in SharePoint.
I’ve tried several formats for the updateData payload. My most recent attempt sugested by copilot was:
updateData = {
"users": {
"@odata.type": "Collection(SP.FieldLookupValue)",
"results": [
{
"LookupId": 9
},
{
"LookupId": 12
}
]
}
};
Despite this, the field still doesn’t update. I’ve also experimented with other formats, such as passing an array of IDs directly, but none have worked for the multi-value case.
Could you please provide guidance on the correct payload format for updating a multi-value lookup field using the Microsoft Graph API? Any examples or documentation references would be greatly appreciated.