搜索用户无法使用 ms graph java SDK

Search for users can't get it to work with ms graph java SDK

我正在尝试做的事情通过图形浏览器运行良好,甚至从我的日志中复制 URL 也能运行:

https://graph.microsoft.com/v1.0/users?%24search=%22displayName%3Adummy%22&%24select=id%2CdisplayName&%24orderby=displayName

预期结果:

Returns 仅匹配显示名称中包含 dummy 的用户

实际结果:

匹配目录中的所有用户

        final OkHttpClient graphHttpClient = HttpClients.createDefault(authProvider)
                .newBuilder()
                .addInterceptor(logging)
                .build();

        DefaultLogger defaultLogger = new DefaultLogger();
        defaultLogger.setLoggingLevel(LoggerLevel.DEBUG);

        GraphServiceClient<Request> graphClient = GraphServiceClient
                .builder()
                .logger(defaultLogger)
                .httpClient(graphHttpClient)
                .buildClient();
        LinkedList<Option> requestOptions = new LinkedList<>();
        requestOptions.add(new QueryOption("$search", "\"displayName:dummy\""));
        UserCollectionPage users = graphClient.users()
                .buildRequest(requestOptions)
                .select("id,displayName")
                .orderBy("displayName")
                .get();

        users.getCurrentPage(); // contains all users in my directory, not just the searched one

Maven 坐标:

        <dependency>
            <groupId>com.microsoft.graph</groupId>
            <artifactId>microsoft-graph</artifactId>
            <version>3.2.0</version>
            <exclusions>
                <exclusion>
                    <groupId>com.azure</groupId>
                    <artifactId>azure-core-http-netty</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.azure</groupId>
            <artifactId>azure-core-http-okhttp</artifactId>
            <version>1.6.1</version>
        </dependency>

您需要添加 header "ConsistencyLevel" = "eventual" 才能使其正常工作。