jay
jay

Reputation: 1175

Use search Microsoft Graph API C#

I am trying to filter the ToReceipient using Graph API in C#.

as per Unable to filter messages by recipient in Microsoft Graph Api. One or more invalid nodes

at the moment Filter does not support ToRecipient. I need to use Search.

However in c# as per screenshot and code below, it does not seem to have search property, only filter. Anyone knows how to use Search in Graph API c#? I also need to filter it based on multiple toRecipient Email addresses. Thanks.

IUserMessagesCollectionPage msgs = await client.Users["[email protected]"].Messages.Request().Filter ==> exist

IUserMessagesCollectionPage msgs = await client.Users["[email protected]"].Messages.Request().Search ==> does not exist

enter image description here

Upvotes: 2

Views: 2457

Answers (1)

Shiva Keshav Varma
Shiva Keshav Varma

Reputation: 3585

You can try using QueryOptions class as below.

List<QueryOption> options = new List<QueryOption> 
{            
    new QueryOption("$search", "lunch") 
}; 

var messages = await client.Users["[email protected]"].Messages.Request(options).GetAsync();

You can also use filter, top and other query parameters as well.

Upvotes: 4

Related Questions