使用SharePoint 2013 REST API添加列表项



我正在尝试使用带有REST API的SharePoint 2013在现有列表中添加新项。

这里有相当好的文档:http://msdn.microsoft.com/en-us/library/jj164022(office.15).aspx#ListItems

我试图添加项目的列表被称为"资源",因此我执行以下httpPOST操作来添加新项目:

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"),但我想这是不对的。

如何找到我的列表的名称?

您可以获得如下名称:

GET https://<site>/apps/reserve/_api/lists/getbytitle('Resources')?$select=ListItemEntityTypeFullName

列表名称将位于:content->m:properties->d:ListItemEntityTypeFullName

最新更新