Search code examples
microsoft-graph-apioutlook-graph-api

Filter out declined events


I need to use microsoft graph api, more in detail the calendar one, to retrieve some events of the users (up to 1000 entries). I need to filter out the events that the user have declined. That information is stored in the assignee resource, or conveniently in the 'responseStatus' property.

The issue that I'm having is that anytime I try to retrieve the assignee resource, the query takes 10x time to perform (from 1.2s without the assignees to 12-14s with). (https://graph.microsoft.com/v1.0/me/events?select=id,subject,start,end,sensitivity,assignee&top=1000)

So i've tried to get the responseStatus instead and...guess what, the performance are always 10x worst (https://graph.microsoft.com/v1.0/me/events?select=id,subject,start,end,sensitivity,responseStatus&top=1000)

I've then decided to try to filter them directly (https://graph.microsoft.com/v1.0/me/events?select=id,subject,start,end,sensitivity,responseStatus&top=1000&filter=responseStatus/response ne 'declined') but I receive an error message stating that "The property 'responseStatus' does not support filtering."

And I'm having an hard time filtering the assignee resource.

So...is there a simple way to filter declined events without having such performance issues?


Solution

  • You can use the extended property pidlidresponsestatus https://learn.microsoft.com/en-us/office/client-developer/outlook/mapi/pidlidresponsestatus-canonical-property to filter those out eg

    https://graph.microsoft.com/v1.0/me/events?$select=subject,body,bodyPreview,organizer,attendees,start,end,location,responsestatus&$filter=singleValueExtendedProperties/any(ep:ep/id eq 'Integer {00062002-0000-0000-C000-000000000046} Id 0x8218' and cast(ep/value, Edm.Int32) ne 4)