What I'm trying to do works fine through the graph explorer, and even copying the URL from my logs works too:
Expected result:
Returns only matching users containing dummy in their display name
Actual result:
Matches all users in directory
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 co-ordinates:
<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>
You need to add a header "ConsistencyLevel" = "eventual"
to get it to work.