我正在尝试使用SharePoint 2013和REST API在现有列表中添加新项。
这里有非常好的文档:http://msdn.microsoft.com/en-us/library/jj164022(office.15).aspx#ListItems
我要添加项的列表名为“Resources”,所以我执行以下HTTP POST操作来添加新项:
POST https://<site>/apps/reserve/_api/lists/getbytitle('Resources')/items
X-RequestDigest: <digest_key>
Content-Type: application/json;odata=verbose
{
"__metadata": {"type": "SP.Data.ResourcesListItem"},
"Title": "New Title",
"Description": "New Description",
"Location": "Sunnyvale"
}
但我收到了以下错误信息:
A type named 'SP.Data.ResourcesListItem' could not be resolved by the model.
When a model is available, each type name must resolve to a valid type.
所以我猜测我没有正确的名称来表示这个资源的名称。在文档中,它说:
To do this operation, you must know the ListItemEntityTypeFullName property of the list
and pass that as the value of type in the HTTP request body.
但我不知道如何获取我的列表的ListItemEntityTypeFullName,而且文档似乎没有解释如何做到这一点 - 我复制了文档中的模式(SP.Data.<LIST_NAME> ListItem"),但我想那不对。
我该如何找到我的列表名称?
Field=SomeName
的内容。SomeName
是你想要的。2)如果你没有访问“列表设置”的权限,你可以转到http://yoursite/_vti_bin/listdata.svc/ListName
(SP 2010)或http://yoursite/_api/Web/Lists/GetByTitle('ListName')
(SP 2013+)。字段名称将在<feed><entry><content><m:properties><d:SomeName>Your Display Name</d:SomeName>
下(在 2013+ 中省略 <feed>)。 - vapcguy