我需要删除所有日历事件。
我看到了API,这是删除所有事件的方法:
// Clear a calendar
service.calendars().clear('primary').execute();
所以,我在我的代码中这样做:
service.calendars().clear(CALENDAR_ID).execute();
我有必要的授权,但我有这个错误:
{
"code" : 400,
"errors" : [ {
"domain" : "global",
"message" : "Cannot clear primary calendar.",
"reason" : "invalid"
} ],
"message" : "Cannot clear primary calendar."
}.
我该如何解决这个问题?
日历:清除
清除主日历。此操作删除所有事件与帐户的主日历相关联。
它只适用于您需要进行的主日历
service.calendars().clear('primary').execute();
不使用日历id。
也有同样的问题。试着从日历中删除所有的even,因为其中一些已经被窃听,不可能一个接一个地删除。例如:
1:
kind "calendar#event"
etag ""3137773029614000""
id "3s3rabieiic4602kq267cu5t6n"
status "cancelled"
2:
kind "calendar#event"
etag ""3137773029614000""
id "3s3rabieiic4602kq267cu5t6n_20180627T080000Z"
status "cancelled"
recurringEventId "3s3rabieiic4602kq267cu5t6n_R20180627T080000"
originalStartTime
dateTime "2018-06-27T10:00:00+02:00"
timeZone "Europe/Paris"
正如你所看到的,它们的ID大致相同。我还有6个类似的ID。