PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, June 28, 2022

[FIXED] How to specify search option with MS graph java SDK

 June 28, 2022     graph, microsoft-graph-api, msgraph, outlook-graph-api     No comments   

Issue

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.


Solution

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();


Answered By - user2250152
Answer Checked By - Willingham (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing