No results when filtering a CalendarView by an extended Property

386 views Asked by At

I am using the Microsoft Graph C# SDK to retrieve certain calendar events from users. Using the method

var calendarView = await graphClient.Users[mail].CalendarView.Request(
    new List<QueryOption>()
    {
        new QueryOption("startDateTime", $"{DateTime.Now.AddMonths(-1).ToString("s")}"),
        new QueryOption("endDateTime", $"{DateTime.Now.AddMonths(1).ToString("s")}")
    })
    .Expand("singleValueExtendedProperties($filter=id eq 'String {MY-GUID-HERE} Name Creator')")
    .GetAsync();

works fine. I get my events for the time frame along with the custom properties. Now, I only want to catch this event from the list, that has the following properties:

Microsoft.Graph.EventSingleValueExtendedPropertiesCollectionPage
Id: 'String {MY-GUID-HERE} Name Creator'
Value: 'SyncUser'

So following the docs I add the Filter() method.

var calendarView = await graphClient.Users[mail].CalendarView.Request(
    new List<QueryOption>()
    {
        new QueryOption("startDateTime", $"{DateTime.Now.AddMonths(-1).ToString("s")}"),
        new QueryOption("endDateTime", $"{DateTime.Now.AddMonths(1).ToString("s")}")
    })
    .Filter("singleValueExtendedProperties/Any(ep: ep/id eq 'String {MY-GUID-HERE} Name Creator' and ep/value eq 'SyncUser')")
    .Expand("singleValueExtendedProperties($filter=id eq 'String {MY-GUID-HERE} Name Creator')")
    .GetAsync();

and I get zero results back. I did check the query, the GUID, the value, copy the values, everything. However, the query still produces no results. Commenting out the Filter method however returns the entire list with the item that I am looking for.

UPDATE: I exposed the HttpRequestMessage from my first program (Expand() only) so I could use the url in Graph Explorer. Despite my C# program working with the same url, using Graph I get the following error:

GET https://graph.microsoft.com/v1.0/me/calendarview?startdatetime=2020-09-02T07:34:05.397Z&enddatetime=2020-10-09T07:34:05.397Z&$expand=singleValueExtendedProperties($filter=id%20eq%20'String%20%7BMY-GUID-HERE%7D%20Name%20Creator')

{
    "error": {
        "code": "BadRequest",
        "message": "Parsing OData Select and Expand failed: Found an unbalanced bracket expression.",
        "innerError": {
            "date": "2020-10-02T07:38:40",
            "request-id": "50f365a4-d936-4173-a650-ed7f318da08f",
            "client-request-id": "c4669369-61f5-016d-cb2c-efd1b738c5af"
        }
    }
}

And the second one (Expand and Filter):

GET https://graph.microsoft.com/v1.0/me/calendarView?startDateTime=2020-08-02T09:41:09&endDateTime=2020-12-02T09:41:09&$filter=singleValueExtendedProperties/Any(ep: ep/id eq 'String {MY-GUID-HERE} Name Creator' and ep/value eq 'SyncUser')&$expand=singleValueExtendedProperties($filter=id eq 'String {MY-GUID-HERE} Name Creator')    

returns the exact same error message.

1

There are 1 answers

0
Shiva Keshav Varma On

There are some limitations on the OData query parameters where 'Expand' and 'Filter' cannot be worked combinedly as specified in the Known Issues. Please raise a feature request specifying this API call in the Microsoft Graph Feedback Forum so that the product team could implement it in the future.