如何使用oData查询从Azure图形API过滤结果

时间:2019-06-27 09:44:39

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

我正在尝试从图形API过滤结果。我有20位用户。我想使用用户名以“ s”开头的通配符进行搜索,因此所有用户名均来自“ s”。为此,我正在尝试使用odata查询

public class gpio {

    public static void main(String[] args) throws InterruptedException {
        final GpioController gpio = GpioFactory.getInstance();
        final GpioPinDigitalOutput pin = 
    gpio.provisionDigitalOutputPin(RaspiPin.GPIO_07, "MyLED", PinState.HIGH);
        pin.setShutdownOptions(true, PinState.LOW);

        // toggle the current state of gpio pin #01 (should turn on)
        pin.toggle();
        System.out.println("--> GPIO state should be: ON");
        // toggle the current state of gpio pin #01  (should turn off)
        pin.toggle();
        System.out.println("--> GPIO state should be: OFF");
}
}

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

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

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

TIA

1 个答案:

答案 0 :(得分:0)

使用/ users API通过signInNames筛选用户时,ODATA查询表达式仅支持equals-match。 例如:

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'))

方法: GET

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

希望它是有用的。