I was passing a .Net DateTime to each of the Event's EventDateTime (Start and End) objects. The .Net DateTime was carrying my localized time zone with it.
So, I tried DateTime.ToString("yyyy-MM-ddTHH:mm:ss"). Great! I've now managed to make sure the time zone doesn't get populated. Setting the TimeZone property now results in appropriate results.
Next, I want to pass a null or empty time zone so that the Calendar's default time zone is used. So I tried null and I tried "". In both cases, I get:
Google.GoogleApiException
HResult=0x80131500
Message=Google.Apis.Requests.RequestError
Missing time zone definition for start time. [400]
Errors [
Message[Missing time zone definition for start time.] Location[ - ] Reason[required] Domain[global]
Message[Missing time zone definition for end time.] Location[ - ] Reason[required] Domain[global]
]
Source=Google.Apis
StackTrace:
at Google.Apis.Requests.ClientServiceRequest`1.<ParseResponse>d__31.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Google.Apis.Requests.ClientServiceRequest`1.Execute()
at RPSGoogleCalendarHelper.CalendarHelper.CreateCalendarEntry(String ApplicationName, String CalendarID, String ClientSecrets, String CredentialWriteablePath, Boolean CredentialPathIsFullPath, Boolean TryUpsert, String ICalUID, String ID, List`1 Attendees, String Summary, String Description, String TimeZone, DateTime StartDateTime, DateTime EndDateTime, String Address) in C:\Users\Saro\git\RPSInteropUtils\RPSGoogleCalendarHelper\CalendarHelper.cs:line 343
at RPSGoogleCalendarHelper.CalendarHelper.CreateCalendarEntry(String ApplicationName, String CalendarID, String ClientSecrets, String CredentialWriteablePath, Boolean CredentialPathIsFullPath, Boolean TryUpsert, String ICalUID, String ID, String AttendeeEmailAddressesDelimited, String Summary, String Description, String TimeZone, DateTime StartDateTime, DateTime EndDateTime, String Address, String Delimiter) in C:\Users\Saro\git\RPSInteropUtils\RPSGoogleCalendarHelper\CalendarHelper.cs:line 186
I've had to resort to storing time zones for each calendar I'm working with - but this seems to go against what the API docs say is required.