There's an all-day event on Google calendar, I pulled it, change it to 1-hour event, I created patch event to push back. As I understand, an all-day event has "start" as a Date, and "end" as the following date. Time-limited event have those in DateTime.
So in my patch, I tried changing those values from Date to DateTime. However, I always receive the error "Invalid or mismatching start and end times".
I tried this manually on Google Calendar API site: https://developers.google.com/google-apps/calendar/v3/reference/events/patch#try-it and getting the same error. If I take a time-limited event and modify it, no trouble occurs. I believe this is a bug in the API itself. Anyone experiences it and what's the workaround? Thanks in advance.
Updated: this is what I received from google dev team, hope useful to sb:
Comment #4 on issue 3110 by [email protected]: patching event from all-day to non all-day failed http://code.google.com/a/google.com/p/apps-api-issues/issues/detail?id=3110
Patch operation takes the original event and changes/adds/removes entries specified by the request. If you send following request to PATCH operation against all-day event:
{
"start": {
"dateTime": "2012-05-17T06:30:00+06:30",
"timeZone": "UTC"
},
"end": {
"dateTime": "2012-05-17T07:30:00+06:30",
"timeZone": "UTC"
}
}
the resulting event would end-up with both dateTime and date fields set (which is not allowed). Hence, the PATCH request needs to clear the date fields:
{
"start": {
"dateTime": "2012-05-17T06:30:00+06:30",
"timeZone": "UTC",
"date": null
},
"end": {
"dateTime": "2012-05-17T07:30:00+06:30",
"timeZone": "UTC",
"date": null
}
}
In code, when you want to set the field Date to null, you have to put Data.NULL_DATE_TIME
like this:
EventDateTime edt = new EventDateTime();
edt.put("date",Data.NULL_DATE_TIME);// if you put NULL, it doesn't retain.
edt.put("dateTime", newTime); //newTime is the new value you want to set, type DateTime
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With