首页 > 解决方案 > 谷歌日历 api 删除未来事件

问题描述

我正在尝试从它告诉您使用的文档events.update()中删除未来的谷歌日历事件,而我得到的最接近的是:

Events events = calendar.events().instances("primary", eventId).execute();
        Event instance = events.getItems().get(0);
        String[] recurrence = new String[]{"RRULE:UNTIL=" + new DateTime(new Date())};
        instance.setRecurrence(Arrays.asList(recurrence));
        calendar.events().update("primary", eventId, instance).execute();

并给我以下内容:

com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
{
  "code": 400,
  "errors": [
    {
      "domain": "global",
      "message": "Value 'k6nni7i7p54hb82p3p6eh9emg8_20180830T174500Z' in content does not agree with value 'k6nni7i7p54hb82p3p6eh9emg8'. This can happen when a value set through a parameter is inconsistent with a value set in the request.",
      "reason": "invalidParameter"
    }
  ],
  "message": "Value 'k6nni7i7p54hb82p3p6eh9emg8_20180830T174500Z' in content does not agree with value 'k6nni7i7p54hb82p3p6eh9emg8'. This can happen when a value set through a parameter is inconsistent with a value set in the request."
}

任何帮助将不胜感激,谢谢!

标签: javagoogle-calendar-api

解决方案


使用 Calendar API 删除事件将使用events.delete。您可以使用 Try-it 进行测试。


推荐阅读