Search code examples
pythongoogle-calendar-apibulkasp.net-web-api

Python Google Calendar API trouble


I am able to add multiple events to Google Calendar in bulk, but this is only in my default calendar. How would I be able to get the same code to work with another calendar that I have the URL for?

request_feed = gdata.calendar.CalendarEventFeed()

# add events to the request_feed
request_feed.AddInsert(entry=InsertSingleEvent(calendar_service, "walk the dog at 4:00pm"))
request_feed.AddInsert(entry=InsertSingleEvent(calendar_service, "walk the cat at 5:00pm"))

response_feed = calendar_service.ExecuteBatch(request_feed,
gdata.calendar.service.DEFAULT_BATCH_URL))

This will work fine and all the events will appear in my calendar right after. But when I replace:

response_feed = calendar_service.ExecuteBatch(request_feed,
gdata.calendar.service.DEFAULT_BATCH_URL))

With:

url = 'calendar/feeds/.../private/full'
response_feed = calendar_service.ExecuteBatch(request_feed,
url))

I get errors:

gaierror: [Errno 11004] getaddrinfo failed

Also please note that I have been able to use that URL to add events by themselves.


Solution

  • Looking at the code, it seems that:

    DEFAULT_BATCH_URL = 'http://www.google.com/calendar/feeds/default/private/full/batch'
    

    In your code, it looks like it is trying to resolve a partial URL. If you format the URL as:

    url = 'http://www.google.com/calendar/feeds/.../private/full/batch'
    

    It should work.