【问题标题】:how to filter result from azure graph API using oData query如何使用 oData 查询从 azure graph API 过滤结果
【发布时间】:2019-07-17 13:31:27
【问题描述】:

我正在尝试从图形 api 过滤结果。我有 20 个用户。我想用's'开头的用户名进行通配符搜索,所以所有用户名都来自's'。为此我正在尝试odata查询

signInNames/any(x:x/ startswith(value,'s'))

所以我正在查找所有用户名,名称以 s 开头。下面是图形功能。

var JSON2 = await SendGraphRequest("/users/", $"$filter=signInNames/any(x:x/ startswith(value,'r'))", null, HttpMethod.Get);

I have also attached json data screenshot, from i have to filter the result

TIA

【问题讨论】:

    标签: c# json odata azure-ad-graph-api


    【解决方案1】:

    使用 /users API 通过 signInNames 过滤用户时,ODATA 查询表达式仅支持等于匹配。 例如:

    https://graph.windows.net/myorganization/users?$filter=signInNames/any(c:c/value eq '***')
    

    如果你尝试通过startswith过滤用户,你会得到如下错误: 网址:

    https://graph.windows.net/myorganization/users?$filter=signInNames/any(c:startswith(c/value, 'm'))
    

    方法: 获取

    Response:
    {
        "odata.error": {
            "code": "Request_UnsupportedQuery",
            "message": {
                "lang": "en",
                "value": "value only supports equals-match. PrefixMatch is not supported."
            },
            "requestId": "aa3f1c9a-abec-425b-b187-a669a6d69cd9",
            "date": "2019-07-17T04:55:47"
        }
    }
    

    希望它有用。

    【讨论】:

      猜你喜欢
      • 2015-11-28
      • 2019-03-17
      • 1970-01-01
      • 1970-01-01
      • 2014-03-12
      • 1970-01-01
      • 1970-01-01
      • 2015-11-28
      • 2022-01-22
      相关资源
      最近更新 更多