Google Calendar API - can only update event once

陌路散爱 提交于 2019-12-05 13:15:35

Make sure to increment the sequence number field when updating events.

rob_mac

I had same problem. To increment the sequence number you need to keep track of how many updates you have done and include the next increment in your update. For some reason the first update doesn't require this but subsequent updates do require it.

Using the google php library on your 2nd update to the event would look something like this (minus whatever else your are updating):

$calendarID = ID_OF_YOUR_CALENDAR;
$eventID = ID_OF_YOUR_EVENT;

$event = new Google_Event();
$event->setSequence('2');

$calEvent = $cal->events->update($calendarID $eventID, $event);

That is how I do it. Fetch the entry from Google so it already has the latest Etag set and increment the sequence by one and update the entry.

As I use java so following is a example with java:

com.google.api.services.calendar.model.Event googleCalendarEvent = service.events().get(clientCalendarEvent.getCalendar().getCalendarKey(),clientCalendarEvent.getEventKey()).execute();
updateGoogleCalendarEvent(clientCalendarEvent, googleCalendarEvent);

googleCalendarEvent.setSequence(googleCalendarEvent.getSequence() + 1);

com.google.api.services.calendar.model.Event event = service
      .events()
      .update(clientCalendarEvent.getCalendar().getCalendarKey(), clientCalendarEvent.getEventKey(),
          googleCalendarEvent).execute();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!