【发布时间】:2018-01-18 12:17:59
【问题描述】:
我正在尝试使用 ajax 调用从 Jquery 中获取几个 SharePoint(2013) 列表,如下所示
$.ajax({
url: url + "/_api/web/lists/getbytitle('" + listname + "')/items?$top="+maxReturnedRows,
method: "GET",
async: false,
headers: { "Accept": "application/json; odata=verbose" },
success: function (data) {
listArray = data.d.results;
},
error: function (data) {
alert('Error in AJAX-Call to '+listname);
failure(data);
}
});
其中 url 包含 SharePoint 网站的 URL。 这个电话给了我以下错误,
错误代码:-1,System.Collections.Generic.KeyNotFoundException 错误消息:给定的键不在字典中。
JSON 响应:-
"{\"error\":{\"code\":\"-1, System.Collections.Generic.KeyNotFoundException\",\"message\":{\"lang\":\"de-DE\",\"value\":\"The given key was not present in the dictionary.\"}}}"
我已尝试使用以下 URL 在浏览器中调试问题
<baseurl>+ "/_api/web/lists/getbytitle('" + listname + "')
我收到了带有 List Metada 的 XML 响应,但如果我尝试使用以下 URL 获取该列表中的项目,
<baseurl> + "/_api/web/lists/getbytitle('" + listname + "')/Items
我收到 500 错误,我怀疑是因为同样的问题。
作为另一种选择,尝试使用 'guid' 获取相同的列表,如下所示,
<baseurl>/_api/Web/Lists(guid'xxxxxxxxxxxxxxx')
如果我尝试访问此列表的项目,它正在工作,我收到错误 500
<baseurl>/_api/Web/Lists(guid'xxxxxxxxxxxxxxx')/Iems
请告诉我,如何解决此问题。
提前致谢
【问题讨论】:
标签: javascript jquery ajax list sharepoint-2013