Craig Younkins
Craig Younkins

Reputation: 1430

Calendar events $filter query on start/timeZone in Microsoft Graph API

I'd like to apply a filter to the https://graph.microsoft.com/v1.0/me/calendars/<calendar>/events endpoint by providing the OData v4.0 $filter as a query parameter, but applying eq to start/timeZone results in an error:

When $filter is subject eq 'My Subject' and start/dateTime eq '1970-01-01T00:00:00.0000000' and end/dateTime eq '1970-01-01T00:01:00.0000000' and start/timeZone eq 'UTC' and end/timeZone eq 'UTC' I get back:

{
  "error": {
    "code": "InvalidDateTime",
    "message": "The value 'UTC' of parameter 'DateTime' is invalid.",
    "innerError": {
      "request-id": "68f797e2-5059-4a8a-8fc6-0063e31d6498",
      "date": "2019-06-07T13:46:54"
    }
  }
}

The documentation references the Prefer: outlook.timezone header, but only indicates that it applies to the response, and says nothing about interpreting the request:

For all GET operations that return events, you can use the Prefer: outlook.timezone header to specify the time zone for the event start and end times in the response.

How can I filter on the (dateTime, timeZone) combination? It would be best if I didn't have to know the timeZone of the event and could instead query based on UTC, but I don't see how to do that either.

Thank you!

Upvotes: 2

Views: 4184

Answers (1)

Marc LaFleur
Marc LaFleur

Reputation: 33094

You can't filter on timeZone and you shouldn't have too. All DateTime values are stored in UTC. They are only converted into a local time zone when you include Prefer: outlook.timezone

You should be able to simply use

subject eq '{subject}' and start/dateTime eq '{date}T{time}' and end/dateTime eq '{date}T{time}'

Upvotes: 4

Related Questions