【问题标题】:$orderby with $filter doesn't seem to work as documented带有 $filter 的 $orderby 似乎不像记录的那样工作
【发布时间】:2020-06-16 16:23:16
【问题描述】:

我正在尝试访问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-api


    【解决方案1】:

    为此,您需要:

    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。

    请查看Documentation

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-04-04
      • 2016-02-27
      • 1970-01-01
      • 1970-01-01
      • 2018-10-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-03
      相关资源
      最近更新 更多