[英]Adding list items with SharePoint 2013 REST API
我正在嘗試使用帶有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"
}
但是我收到了以下錯誤:
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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.