Sadashiv
Sadashiv

Reputation: 437

How to specify search option with MS graph java SDK

IMessageCollectionRequest eventRequest = graphClient.getGraphClient().users(user.getEmail()).messages()
                .buildRequest(new HeaderOption("Prefer", "outlook.body-content-type=\"text\""))
                .select("body,subject,toRecipients,ccRecipients,CreatedDateTime,conversationId,from");

IMessageCollectionPage eventPage = eventRequest
                                  .filter(filter)
                                  .get();

In the above code I am able to get results based on specified filter.

Now I want below search to be performed insteat of filter as MS graph does not support both of these to be applied.

https://graph.microsoft.com/v1.0/users/{{UserId}}/messages?$search="recipients:@xyz.com" & $top=1000

How can we specify search condition instead of filter. exactly shown in the above URL usig java SDK.

Upvotes: 0

Views: 1309

Answers (1)

user2250152
user2250152

Reputation: 20605

You can specify options in buildRequest.

LinkedList<Option> requestOptions = new LinkedList<Option>();
requestOptions.add(new QueryOption("$search", "\"recipients:@xyz.com\""));

MessageCollectionPage messages = graphClient.users("{UserId}").messages()
    .buildRequest( requestOptions )
    .top(1000)
    .get();

Upvotes: 3

Related Questions