question

JanNiclas-1155 avatar image
0 Votes"
JanNiclas-1155 asked RzCyrill-9550 published

MS Graph: Cannot update Person or Group Field in Sharepoint list

I am trying to update the contents of a person or group field of a specific item in a Sharepoint list. However searching through the docs I could not find any examples, so I created a flow that does just that to take a look at the code. Pasting the code into MS Graph Explorer returns a 200 but does not change anything. Updating fields like the title, links or whatsoever work. I am using a PATCH request with the url:

https://graph.microsoft.com/v1.0/sites/XXXXXXXXX/lists/MYLIST/items/4

and the following body:
{
"MYPERSONORGROUPFIELD": [
{
"Claims": "someuser@contoso.com"
}
]
}

microsoft-graph-sites-lists
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Try it like this:

{
"fields": {
"StellvertretungLookupId@odata.type": "Collection(Edm.String)",
"StellvertretungLookupId": [
"25",
"11"
]
}
}

You will get the ID's from the ensure API, i did this via sphttpclient and i'm not sure if this is available over graph.
got the idea from here: https://stackoverflow.com/questions/47010078/how-to-update-a-lookup-field-and-a-user-field-in-sharepoint-with-microsoft-graph

0 Votes 0 ·

1 Answer

Deva-MSFT avatar image
0 Votes"
Deva-MSFT answered JanNiclas-1155 commented

Say, you have field "Category" then if it's lookup field is single, then you want to try the below and see if it helps.

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

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

For single lookup fields it works, like you mentioned or how I did it. I also tested it again, but unfortunately it does not work for multiple choice fields. When using only one value I am getting a 500 error. Do you have any examples for these?

0 Votes 0 ·