我在 SharePoint Online 中使用 ms-graph。
我有一个简单的列表,其中包含一个标题列和 3 个项目。
我使用以下 ms-graph 调用按标题过滤项目:
https://graph.microsoft.com/v1.0/sites/root:/lists/list-guid/items?expand=fields&filter=startswith(fields/Title,%27fig%27)
结果是错误信息:
Field 'Title' cannot be referenced in filter or orderby as it is not indexed. Provide the 'Prefer: HonorNonIndexedQueriesWarningMayFailRandomly' header to allow this, but be warned that such queries may fail on large lists.
我知道这个调用在我使用 SharePoint REST API 之前和之前都有效,然后我可以毫无问题地过滤列表。我也试过不同的租户。
另一个事实是相同的调用在没有开始过滤器的情况下也能工作。
几天前,我收到了同一个电话的不同信息。
"Field 'Title' cannot be referenced in filter or orderby as it is not indexed. Provide the 'allowthrottleablequeries' preference to allow this, but be warned that such queries may fail on large lists."
最佳答案
关于以下错误:
Field 'Title' cannot be referenced in filter or orderby as it is not indexed. Provide the 'Prefer: HonorNonIndexedQueriesWarningMayFailRandomly' header to allow this, but be warned that such queries may fail on large lists.
过滤时至少有两个选项可以克服此错误。
选项 1. 向 SharePoint 列添加索引
曾经index to a SharePoint column参与过滤的创建,该错误应该不再出现。
选项 2. 附加标题
Prefer:HonorNonIndexedQueriesWarningMayFailRandomly
正如错误消息所述,将指定的 header 附加到请求中,例如在 Graph Explorer 中:
关于microsoft-graph-api - Microsoft Graph HonorNonIndexedQueriesWarningMayFailRandomly 过滤 SharePoint Online 列表时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49169917/