以前有效的 Microsoft Graph 请求上的 InefficientFilter 错误 [英] InefficientFilter error on Microsoft Graph requests which were previously working

查看:15
本文介绍了以前有效的 Microsoft Graph 请求上的 InefficientFilter 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

向 MS Graph 发出以下请求,以检索按到期日期排序的标记消息:

Making the following request to the MS Graph to retrieve flagged messages ordered by due date:

https://graph.microsoft.com/beta/me/messages?$filter=flag/flagStatus%20eq%20%27flagged%27&$orderby=flag/dueDateTime/dateTime%20desc&$top=100

以前会成功并返回预期的结果.近期部分用户收到如下回复:

would previously succeed and give back the expected results. Recently some users have been getting the following response:

{
  "error": {
    "code": "InefficientFilter",
    "message": "The restriction or sort order is too complex for this operation.",
    "innerError": {
      "request-id": "5ef714c9-39a0-4167-a4d0-3682dcb46de4",
      "date": "2016-11-17T16:41:16"
    }
  }
}

图表中是否引入了错误?

Has a bug been introduced into the graph?

奇怪的是,这个请求以前很好,现在被认为是低效的.它也只发生在某些用户的帐户上.

It is strange that this request was previously fine, and is now seen as inefficient. It also only happens on some users' accounts.

以下请求检索按接收日期排序的电子邮件附件时也出现了同样的问题:

The same issue has also occurred with the following request to retrieve email attachments ordered by received date:

https://graph.microsoft.com/v1.0/me/messages?$filter=hasAttachments%20eq%20true&$orderby=receivedDateTime%20desc&$expand=attachments($select=name,contentType,size,lastModifiedDateTime)&$top=6

现在得到相同的 InefficientFilter 错误响应.请注意,第二个请求是针对 v1.0 API 的,因此不限于 beta.

which now gets the same InefficientFilter error response. Note, the second request is to the v1.0 API so this is not limited to beta.

另请注意,删除受影响帐户上的 orderby 子句将导致请求成功.

Also note that removing the orderby clause on the affected accounts will cause the requests to succeed.

推荐答案

这是一个 为解决过滤的主要问题而进行的有意(和破坏性)更改.$orderby 仍然很重要.

This was an intentional (and breaking) change made to address a major issue with filtering. $orderby is still very much a thing.

总结该链接,如果您在请求中同时使用 $orderby$filter:

To sum up from that link, if you use both $orderby and $filter in a request:

  1. $orderby 中的任何字段也必须在 $filter 中.
  2. $filter 中的字段顺序很重要:
  1. Any fields in $orderby MUST also be in $filter.
  2. Order of fields in $filter matters:
  1. 同样在 $orderby 中的字段必须在 $filter 中排在第一位,并且顺序必须相同.
  2. 不在 $orderby 中的字段必须在 $orderby 中的字段之后.
  1. Fields that are also in $orderby MUST come first in the $filter and MUST be in the same order.
  2. Fields that are not in $orderby MUST come after the fields that are in $orderby.

因此,根据这些准则,您的请求的问题是 flag/dueDateTime/dateTime 不存在于 $filter 中.

So according to those guidelines, the problem with your request is that flag/dueDateTime/dateTime is not present in $filter.

这篇关于以前有效的 Microsoft Graph 请求上的 InefficientFilter 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆