Google Calendar api v3 re-update issue

2019-01-25 16:58发布

I'm working on google calendar and having problem with syncing data between my Calendar app on Iphone to Google Calendar. (I use google api v3) The problem is: I can update an event by code just 1 time after i created it. The next time when i try to update it, i get message code 400: bad request.

We can use google calendar explore to test this (https://code.google.com/apis/explorer/#_s=calendar&_v=v3&_m=calendars.update) by creating an event then update it 2 time.

Does any one meet this problem?

3条回答
爷的心禁止访问
2楼-- · 2019-01-25 17:41

You cannot update the same event twice. Instead, base your second update request on the new event data that is passed to the callback in the first update call (which has a new eTag) to update it the second time.

查看更多
▲ chillily
3楼-- · 2019-01-25 17:48

Here is a Java code example on how to update using sequence:

Event updatedEvent; 
Calendar Service;   

updatedEvent.setSequence(Service.events().get(mCalendarId, updatedEvent.getId()).execute().getSequence());
Service.events().update(mCalendarId, updatedEvent.getId(), updatedEvent).execute();
查看更多
成全新的幸福
4楼-- · 2019-01-25 17:54

I had this same problem and got the answer here: Google Calendar API v3 - Update Event

You can edit the same event twice, you just have to 'get' the event sequence

$event = $service->events->get("primary", $exist);

$seq=$event['sequence'];

and use $event->setSequence($seq)

when setting your update event details.

查看更多
登录 后发表回答