Saving a Person or Group field using REST
sharepoint, sharepoint-2013
Solution
I haven't done this with a Person field, but I did do something similar with a managed metadata field. I basically had to pass in additional information as an object to create the value in the field.
See if passing in the ID of the user along with the name works. I'm about to try this myself as I have the same need.
{
"MyPersonField": { "Name": "i.0#w|domain\userName", "ID": 1 }
}
EDIT: Ok, updating this field is easier than I thought. I was able to perform the update by simply passing in the ID of the user to the Id field:
{
"MyPersonFieldId": 1
}
This means the user should already be in the site collection, so if the user doesn't exist the request will fail.
Problem
Does anyone know how to save a Person field using REST? I have tried the following and it works: ``` { "__metadata": { "type": "SP.Data.SomeListListItem" } , "MyPersonFieldId" : 1 } ``` But this only works if you know the ID. I don't have that! How can I get it? I have the key which is `i.0#w|domain\userName`. I tried the following and it doesnt work either: ``` { "__metadata": { "type": "SP.Data.SomeListListItem" } , "MyPersonField" : { "__metadata": { "type": "SP.Data.UserInfoItem" }, "Name": "i.0#w|domain\userName" } } ``` Any ideas?? Thanks!