0
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.

Sadashiv
  • 387
  • 1
  • 6
  • 17

1 Answers1

2

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();
user2250152
  • 14,658
  • 4
  • 33
  • 57
  • I tried tis one. I am getting below Exception. com.microsoft.graph.http.GraphServiceException: Error code: BadRequest Error message: Syntax error: character ':' is not valid at position 10 in 'recipients:@xyz.com'. – Sadashiv Nov 03 '21 at 16:59
  • @Sadashiv The value must be surrounded with double quotes. Updated the answer. – user2250152 Nov 04 '21 at 07:16