Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Microsoft Graph - Filtering in SDK C#

Based on another post, I can filter via HTTP requests as follows:

https://graph.microsoft.com/v1.0/me/events?
$filter=categories/any(a:a+eq+'Red+Category')

I am not sure what the a:a stands for here but it works.

I want to replicate this in Microsoft Graph SDK, I am using a query option as per below which does not return any results:

       List<QueryOption> options = new List<QueryOption>
                {
                    new QueryOption("$filter", 
                      "categories/any(a:a+eq+'Red+Category'")
                };        
like image 961
user8608110 Avatar asked Mar 08 '18 11:03

user8608110


1 Answers

You seem to be executing a search instead of a filter in your c# code.

Try using:

var request = graphClient.Users[userId].Events.Request().Filter("categories/any(a:a+eq+'Red+Category')");
var result = await request.GetAsync();

Or alternatively:

 List<QueryOption> options = new List<QueryOption>
                {
                    new QueryOption("$filter", 
                      "categories/any(a:a+eq+'Red+Category')")
                };   
like image 78
Karlheinz Reinhardt Avatar answered Nov 15 '22 08:11

Karlheinz Reinhardt