Do the timezone and time change in the in the result of msgraph-sdk calendar_view.get() ?

Shaun Yang (Medalsoft) 0 Reputation points

I am using python msgraph sdk to query calendar views. Below is my request:

params = {"start_date_time": "2024-05-15T00:00:00+08:00", "end_date_time": "2024-05-15T23:59:59+08:00"}
query_params = CVRBuilder.CalendarViewRequestBuilderGetQueryParameters(
config.query_parameters = query_params

events ="myid").calendar.calendar_view.get(

However, the event.start.date_time for each event in the events changed when I run my code on my desktop in UTC-8 timezone, and a server in US East. The difference of the time is actually the time zone difference. I did not get a chance to print out the event.start.time_zone because when I update my code and restart my server, the issue was gone.

Is there anyone facing the same issue?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,888 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. awijekoon 1,335 Reputation points Microsoft Vendor

    Hi Shaun,

    You could use the Prefer: outlook.timezone header to retrieve events in a specific time zone. This will ensure that the event times are retrieved in the time zone you prefer.

    request_configuration.headers.add("Prefer", "outlook.timezone=\"Pacific Standard Time\"")

    0 comments No comments