[$ orderby with $ filter似乎不如所记载的那样工作

问题描述 投票:0回答:1

我正在尝试达到https://graph.microsoft.com/v1.0/users端点,并且$ filter和$ orderby的几乎任何组合都遇到了问题。关于此组合的docs说:

  1. 出现在$ orderby中的属性也必须出现在$ filter中。
  2. 出现在$ orderby中的属性与$ filter中的顺序相同。
  3. $ orderby中存在的属性出现在$ filter中在没有的任何属性之前。

这似乎暗示这是可能的。这些不是我要运行的真正查询,但是这些是最小表示。一些例子:

$orderby=displayName&$filter=displayName%20eq%20Miriam
$orderby=displayName&$filter=startswith(displayName,'M')
$orderby=displayName&$filter=startsWith(displayName,'M')&$select=displayName

但我总是会收到错误:

"code": "Request_UnsupportedQuery",
"message": "Sorting not supported for current query."

我做错了还是实际上不支持?

microsoft-graph
1个回答
0
投票

要实现这一点,您需要:

  1. 选择Beta端点

  2. 在QueryString中添加$ count = true

  3. 将ConsistencyLevel =最终添加到请求标头中

这样,您将能够实现这一目标,下面是您可以使用的查询

https://graph.microsoft.com/beta/users?$count=true&$filter=startswith(displayName,'M')&$orderby=displayName

注意: Microsoft Graph中/ beta版本下的API可能会发生更改。不支持在生产应用程序中使用这些API。

enter image description here

请检查此Documentation

© www.soinside.com 2019 - 2024. All rights reserved.