I searched high and low to find an example, because what I'm trying doesn't seem to work. I get this error:
com.google.gdata.util.InvalidEntryException: Bad Request
Invalid request URI
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.update(Service.java:1563)
at com.google.gdata.client.Service.update(Service.java:1530)
at com.google.gdata.client.GoogleService.update(GoogleService.java:583)
at CalendarConnect.deleteEvent(CalendarConnect.java:37)
at ProgMain.main(ProgMain.java:26)
Here is an example of the code I'm using:
CalendarService service = new CalendarService("Fourth Year Project");
service.setUserCredentials(username, password);
URL postUrl = new URL("https://www.google.com/calendar/feeds/default/private/full");
CalendarEventEntry myEntry = new CalendarEventEntry();
myEntry.setTitle(new PlainTextConstruct("TEST"));
myEntry.setContent(new PlainTextConstruct("TEST"));
DateTime startTime = DateTime.parseDateTime(StartDateTime);
DateTime endTime = DateTime.parseDateTime(EndDateTime);
When eventTimes = new When();
eventTimes.setStartTime(startTime);
eventTimes.setEndTime(endTime);
myEntry.addTime(eventTimes);
CalendarEventEntry insertedEntry = service.update(postUrl, myEntry);
URL deleteUrl = new URL(insertedEntry.getEditLink().getHref());
service.delete(deleteUrl);
It has been shredded and altered so much that I'm not sure where I am now. Has anyone encountered this issue? If so, how did you overcome it? Someone got a sample code that works, since Google provides only one line of code in its explanation.
source
share