<http://stackoverflow.com/questions/5846797/google-calendar-api-getting-calendar-id-for-new-event-uri#> Hi,
I'm developing an Android APP that connects to Google Calendar. I've been testing some of the features the GData API for Google Calendar and so far I've retrieved all the calendars from an acount, as well as its events. Lately I've been trying to add an entry to a delegate calendar. To add an event to a particular Calendar, I need to send it to and specific address. The URI should be formed like this:"*/private/full*", that looks like this: "*http://www.google.com/calendar/feeds/***** %40group.calendar.google.com/private/full*". The problem is that the CalendarID I get from the CalendarEntry is not a valid URI to create a new event, it adds some additional parameters to the address. It looks like this: "*http://www.google.com/calendar/feeds/ default/calendar/*****%40group.calendar.google.com/private/full*". I've managed to make it work by deleting the "*/default/calendar*" from it, but since this things could change any time, I don't think that is the appropiate way to do it. Does anybody know a more secure and effective way of getting the appropiate URI add an entry to a Calendar? I leave you some of the code I've been using to test. CalendarService calendarService = new CalendarService("CalendarAPP"); calendarService.setUserCredentials(<username>, <password>); String calendarURL = "https://www.google.com/calendar/feeds/default/owncalendars/full"; CalendarFeed resultFeed = calendarService.getFeed(calendarURL, CalendarFeed.class); List<CalendarEntry> entries = resultFeed.getEntries(); for(int i=0; i<entries.size(); i++) { CalendarEntry entry = entries.get(i); CalendarEventEntry myEntry = new CalendarEventEntry(); myEntry.setTitle(new PlainTextConstruct("Tennis with Beth "+i)); myEntry.setContent(new PlainTextConstruct("Meet for a quick lesson.")); DateTime startTime = DateTime.now(); DateTime endTime = DateTime.now(); When eventTimes = new When(); eventTimes.setStartTime(startTime); eventTimes.setEndTime(endTime); myEntry.addTime(eventTimes); String l_URL = entry.getId(); l_URL = l_URL.replaceFirst("/default/calendars", ""); l_URL += "/private/full"; URL postUrl = new URL(l_URL); CalendarEventEntry insertedEntry = connection.getCalendarService().insert(postUrl, myEntry); } Thanks in advance. Mikywan. -- You received this message because you are subscribed to the Google Groups "Google Calendar Data API" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://code.google.com/apis/calendar/community/forum.html
