[英]Adding a sharepoint list item, which has column of type "Person or Group" in it
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
).该列表中有 2 列:
Title
和recipientId
(它的类型为Person
或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:不幸的是,我无法弄清楚我应该给
recipientId
什么值( 这里的一些博客提到我们必须提供用户 id。如果这是正确的,我如何获得该 id 或者我应该在那里为用户提供什么在那里添加?)这是我在邮递员中使用的 json 来创建项目:
{ "__metadata":
{
"type": "SP.Data.List3ListItem"
},
"Title": "Teams incorporate feedback"
}
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
}
Hopefully this might save someone's time,希望这可以节省某人的时间,
so to add a value for a column of type "person or Group"(recipientId in my case).所以要为“person or Group”类型的列添加一个值(在我的例子中是recipientId)。 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 .
首先,我们需要有可以从 REST API https://<site_url>/sites/<site_name>/_api/web/siteusers获取的站点用户 ID。 Once you have the ID, you can add it as value for "UsernameId" key value
获得 ID 后,您可以将其添加为“UsernameId”键值的值
{ "__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).这会将相应的用户名添加到“人员或组”类型的列中(在我的情况下为 recipientId)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.