I am trying to create an event using Microsoft Graph API. The thing which is a bit confusing are date type parameters such as start which is of type dateTimeTimeZone which has two properties, dateTime and timeZone.
{
"subject": "Test body event graph api ist 1",
"start": {
"dateTime": "2018-01-09T12:00:00",
"timeZone": "India Standard Time"
},
"end": {
"dateTime": "2018-01-09T14:00:00",
"timeZone": "India Standard Time"
},
}
For example, I used the above listed values of start and end datetime. That means the event should be created with start date as 9th,January,2018 and time as 12:00:00 pm IST while it should end in 2:00:00 pm IST. However if I look into my calendar the event was scheduled to start at 6:30 am IST and ending at 8:30 am IST. I cannot understand this behaviour. Can someone explain this? So what does the two parameters dateTime and timeZone specify? What are the valid dateTime accepted formats and does dateTime format needs to match to the timeZone? Can someone please explain these things?
You can get a list of supported time zones in the beta version of the Graph API:
GET /me/outlook/supportedTimeZones
The value you are using (India Standard Time
) is a valid value, so this should work. I just tried it and it worked correctly.
REQUEST
POST /me/events
{
"subject": "Test India Appt",
"start": {
"dateTime": "2018-01-09T12:00:00",
"timeZone": "India Standard Time"
},
"end": {
"dateTime": "2018-01-09T14:00:00",
"timeZone": "India Standard Time"
}
}
RESPONSE (truncated)
{
...
"originalStartTimeZone": "India Standard Time",
"originalEndTimeZone": "India Standard Time",
...
"subject": "Test India Appt",
...
"start": {
"dateTime": "2018-01-09T12:00:00.0000000",
"timeZone": "India Standard Time"
},
"end": {
"dateTime": "2018-01-09T14:00:00.0000000",
"timeZone": "India Standard Time"
},
...
}
When you say that you looked at your calendar, how did you do that exactly? Depending on the client you used, the display may have been adjusted to a different time zone.
For example, in the Outlook web client, you set your time zone to a specific one and all events are shown relative to that time zone on your calendar. My test user that I created this appointment with has their time zone set to Pacific Standard Time, so when I look at my calendar, the event I created shows as starting at 10:30 PM on 1/8 and ending at 12:30 AM on 1/9.
Outlook desktop client also shows events relative to the user's time zone, but it uses the time zone of the OS rather than relying on its own setting.