John Staurt
John Staurt

Reputation: 225

Using Microsoft Graph client sdk how would you use search Odata query

Using Microsoft Graph client sdk how would one go about using search Odata query to lookup if subject or body contains a certain search term.

The $search Odata query parameter is available in the Graph Client api, but i could not find how to use the parameter using the client sdk for c#.

Upvotes: 9

Views: 6985

Answers (2)

Tracy
Tracy

Reputation: 670

Piggybacking off of @JohnStaurt's comments above, this worked for me:

List<QueryOption> options = new List<QueryOption>
{
     new QueryOption("$search", "\"displayName:team\" OR \"description:team\"")
};

Upvotes: 2

David
David

Reputation: 2447

You can add any query parameters by passing in a list of QueryOptions to the Request method.

List<QueryOption> options = new List<QueryOption>
{
     new QueryOption("$search", "lunch")
};
var messages = await client.Me.Messages.Request(options).GetAsync();

Documentation: https://github.com/microsoftgraph/msgraph-sdk-dotnet/blob/dev/docs/overview.md#custom-query-options

Upvotes: 19

Related Questions