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

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

问题描述

向MS图表发出以下请求,以检索按到期日期排序的标记邮件:

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"
    }
  }
}

图中是否引入了错误?

奇怪的是,该请求以前没有问题,现在被视为效率低下.它也只会在某些用户的帐户上发生.

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.

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

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

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

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