首页 > 解决方案 > 如何在 SharePoint 2013 中使用“RenderListDataAsStream”端点检索 ListItem

问题描述

这是我使用 RenderListDataAsStream 端点检索列表数据的 ajax 调用。

var payload = {
    'parameters': {
        RenderOptions: 2
    }
};
$.ajax({
    url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists(guid'<list-id>')/RenderListDataAsStream",
    type: "POST",
    headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'X-RequestDigest': $("#__REQUESTDIGEST").val() },
    body: JSON.stringify(payload),
    success: function (data) {
        console.log(data);
    },
    error: function (error) {
        alert(JSON.stringify(error));
    }
});

相同的代码在 SharePoint Online 中运行,但给出如下错误:

{"error":{"code":"-1, Microsoft.SharePoint.Client.ResourceNotFoundException","message":{"lang":"en-US","value":"找不到请求 RenderListDataAsStream 的资源."}}}

此问题仅在 SP2013 中特别存在。

标签: sharepointsharepoint-2013sharepoint-rest-api

解决方案


使用_api/$metadata您可以在您的场中找到可用的 rest api 函数,而根据我的检查,SharePoint 2013 中不存在 RenderListDataAsStream。


推荐阅读