views:

73

answers:

1

Hi there,

I'm trying to retrieve a single CalendarEventEntry from a Google Calendar by the event ID but I can't find the way to do it. It seems that the API doesn't provide a method for this, though it suggests to make a query to the feed calendar using Query. The drawback of this is that the ID is not one of the parameters considered.

I think that a possible way to achieve this would be to get the CalendarEventFeed associated with our calendar and then iterate over the resulting list of events as follows:

CalendarService service = new CalendarService(applicationName);
service.setUserCredentials(userName,password);
CalendarEventFeed myFeed = service.getFeed(feedUrl, CalendarEventFeed.class);
List <CalendarEventEntry> entries =  myFeed.getEntries();

for (CalendarEventEntry e : entries){
    if (e.getId().equals(id)){
       return e;
    }
    }

Do you know any easier and more straight solution to achieve this ??

Thanks in advance!

+1  A: 

You can get the URL of the event by calling calendarEventEntry.getEditLink().getHref(). It is actually the url of the calendar plus the event id.

Take a look at the Data API Developer Guide for code samples.

Kees de Kooter
well, that's alright but it doesn't solve the problem. I'd like to query the calendar feed passing the ID as a parameter and be returned the calendarEventEntry associated with it.
markitus82
I should have been more explicit. You can build the URL yourself: calendar url + forward slash + event id. You do not need a query. Take a look at the "Updating events" paragraph in the developer guide.
Kees de Kooter