Reputation: 513
I am using Microsoft Graph to create an event
. Everything is working except it always creates the event in UTC. I am following the examples from the documentation, but still no luck.
Here is the body of the post:
{
"subject": "My event",
"start": {
"dateTime": "2017-11-03T04:14:31.883Z",
"timeZone": "Eastern Standard Time"
},
"end": {
"dateTime": "2017-11-10T05:14:31.883Z",
"timeZone": "Eastern Standard Time"
}
}
and here is the response:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('...')/events/$entity",
"@odata.etag": "W/\"1OZnj8JcDU6yRK1K4rYSNQABJ3X/lw==\"",
"id": "...",
"createdDateTime": "2017-11-03T04:15:13.7075368Z",
"lastModifiedDateTime": "2017-11-03T04:15:13.7231636Z",
"changeKey": "1OZnj8JcDU6yRK1K4rYSNQABJ3X/lw==",
"categories": [],
"originalStartTimeZone": "UTC",
"originalEndTimeZone": "UTC",
"iCalUId": "...",
"reminderMinutesBeforeStart": 15,
"isReminderOn": true,
"hasAttachments": false,
"subject": "My event",
"bodyPreview": "",
"importance": "normal",
"sensitivity": "normal",
"isAllDay": false,
"isCancelled": false,
"isOrganizer": true,
"responseRequested": true,
"seriesMasterId": null,
"showAs": "busy",
"type": "singleInstance",
"webLink": "...",
"onlineMeetingUrl": null,
"responseStatus": {
"response": "organizer",
"time": "0001-01-01T00:00:00Z"
},
"body": {
"contentType": "text",
"content": ""
},
"start": {
"dateTime": "2017-11-03T04:14:31.8830000",
"timeZone": "UTC"
},
"end": {
"dateTime": "2017-11-10T05:14:31.8830000",
"timeZone": "UTC"
},
}
Upvotes: 3
Views: 732
Reputation: 1
This code snippets works.
invite.Start.TimeZone = eventInvite.TimeZone;
invite.Start.DateTime = eventInvite.StartDateTime.LocalDateTime.ToString("yyyy-MM-ddTHH:mm:ss.fffffff", System.Globalization.CultureInfo.InvariantCulture);
invite.End.TimeZone = eventInvite.TimeZone;
invite.End.DateTime = eventInvite.EndDateTime.LocalDateTime.ToString("yyyy-MM-ddTHH:mm:ss.fffffff", System.Globalization.CultureInfo.InvariantCulture);
Upvotes: 0
Reputation: 59338
Since start
and end
properties represent dateTimeTimeZone
type and DateTime
property expect the value to be specified in yyyy-mm-ddThh:mm[:ss[.fffffff]]
format (see Edm.DateTime type description for more details).
In your example Z
needs to be omitted from 2017-11-10T05:14:31.883Z
since 'Z' is the zone designator for the zero UTC offset, that's the reason why timeZone
property is getting ignored.
For example:
{
"subject": "My event",
"start": {
"dateTime": "2017-11-03T04:14:31.8830000",
"timeZone": "Eastern Standard Time"
},
"end": {
"dateTime": "2017-11-10T05:14:31.8830000",
"timeZone": "Eastern Standard Time"
}
}
Upvotes: 5