kim*_*mon 24 rest sharepoint sharepoint-api sharepoint-2013
我正在尝试使用带有REST API的SharePoint 2013在现有列表中添加新项.
这里有相当好的文档:http://msdn.microsoft.com/en-us/library/jj164022(office.15).aspx#ListItems
我试图添加项目的列表称为"资源",因此我执行以下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"
}
Run Code Online (Sandbox Code Playgroud)
但是我收到了以下错误:
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.
Run Code Online (Sandbox Code Playgroud)
所以我假设我没有资源名称的正确名称.在文档中,它说:
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.
Run Code Online (Sandbox Code Playgroud)
但我不知道如何为我的列表获取ListItemEntityTypeFullName,文档似乎没有解释如何 - 我从文档中复制了模式(SP.Data.<LIST_NAME> ListItem")但我猜这不对.
如何找到列表的名称?
kim*_*mon 22
您可以获得如下名称:
GET https://<site>/apps/reserve/_api/lists/getbytitle('Resources')?$select=ListItemEntityTypeFullName
Run Code Online (Sandbox Code Playgroud)
列表名称将位于:content - > m:properties - > d:ListItemEntityTypeFullName