谷歌日历api删除以后的事件

时间:2018-08-31 02:37:50

标签: java google-calendar-api

我正在尝试从docs删除将来的Google日历事件,它告诉您使用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."
}

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

1 个答案:

答案 0 :(得分:0)

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