Reputation: 31
I am trying to add an item to a list. The list has 2 columns in it: Title
and recipientId
(it is of type Person
or Group
). Now I am using
https:<site url>/_api/web/Lists/getbytitle('list name'>)/items
to create the list. Unfortunately I am unable to figure out what value I should be giving to recipientId
(some blogs here mentioned we have to provide the user id. If that is right, how do I get that id or what exactly I should give there for the user to get added there?) This is the json I am using in post man to create the item:
{ "__metadata":
{
"type": "SP.Data.List3ListItem"
},
"Title": "Teams incorporate feedback"
}
Upvotes: 0
Views: 2304
Reputation: 31
Hopefully this might save someone's time,
so to add a value for a column of type "person or Group"(recipientId in my case). Firstly, we need to have the site users id that you can get from REST API https://<site_url>/sites/<site_name>/_api/web/siteusers. Once you have the ID, you can add it as value for "UsernameId" key value
{ "__metadata":
{
"type": "SP.Data.List3ListItem"
},
"Title": "Varun",
"UsernameId":13
}
this will add the corresponding user name to the column of type "person or Group"(recipientId in my case).
Upvotes: 0
Reputation: 2091
If your column allow mutiple value:
{
"__metadata":{
"type":"SP.Data.TestListItem"//change this value to yours
},
"Title":"Test",
"supervisorId":{
"results":[25,26]//user ids
}
}
If your column only allow single value:
{
"__metadata":{
"type":"SP.Data.TestListItem"
},
"Title":"Test",
"supervisorId":5
}
Upvotes: 1