I'm getting an exception when using the Java Google Calendar API that I can't make heads or tails of. What I'm doing is creating a connector to Google Calendar that inserts events. Some of these events are repeating, and some of those have exceptions to the repeat pattern. I've been very successful in creating events and repeating events, but am having these problems when trying to make exceptions.
The code I'm using is:
CalendarEventEntry gglAppt = new CalendarEventEntry();
OriginalEvent originallink = new OriginalEvent();
originallink.setOriginalId(repeatingEvent.getIcalUID());
When originalWhen = new When();
originalWhen.setStartTime(DateTime.parseDate("2011-05-01"));
originallink.setOriginalStartTime(originalWhen);
When exceptionWhen = new When();
exceptionWhen.setStartTime(DateTime.parseDate("2011-05-10"));
gglAppt.setOriginalEvent(originallink);
gglAppt.setStatus(EventStatus.CANCELED);
gglAppt.addTime(exceptionWhen);
try {
//I can vouch for this line, it works elsewhere in the code.
//CalendarServiceManager is a custom class if you didn't guess ;-)
CalendarServiceManager.getInstance().addNewEvent(gglAppt, http://www.google.com/calendar/feeds/default/calendars/testemail%40gmail.com);
} catch (IOException e) {
e.printStackTrace();
} catch (ServiceException e) {
e.printStackTrace();
}
The exception is:
com.google.gdata.util.InvalidEntryException: Bad Request
Element must contain value for attribute id
at com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataRequest.java:594)
at com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataRequest.java:563)
at com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.java:552)
at com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:530)
at com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:535)
at com.google.gdata.client.Service.insert(Service.java:1409)
at com.google.gdata.client.GoogleService.insert(GoogleService.java:599)
at com.testapp.google.CalendarServiceManager.addNewEvent(CalendarServiceManager.java:138)
at com.testapp.google.GoogleAdapter.dealWithExceptions(GoogleAdapter.java:581)
...etc
My understanding from what I've seen around the interwebs is that an attribute ID is something you set for Google objects for you to keep track of them. I wouldn't know where to set an attribute ID, and I'm puzzled as to why I haven't had to set an attribute ID for any of the other events I've submitted.
What is this exception that's being thrown? What does it mean and what do I do about it?
Any help would be greatly appreciated as always.
Found the answer to my question here:
Turns out repeatingEvent didn't have an id yet. I had just created it and sent it off to the server, but hadn't updated the local object with the one returned from the server; the one with an id.