Search code examples
pythonapicalendargoogle-apigoogle-api-python-client

Adding attendees with Google Calendar API


I'm trying to add attendees to an inserted event using the Python Google Calendar API. Any idea where I'm going wrong? I have tried and read everything I could find on it. Thanks.

brew_cal_body = {'attendees':{'email':'*********@gmail.com'},'end':{'date':'2014-08-20'},'start': {'date':'2014-08-18'},'summary':'TESTING THINGS'}

new_event = google_calendar.service.events().insert(calendarId=brew_cal_id, body=brew_cal_body,sendNotifications=True).execute()

new_event

{u'created': u'2014-08-15T19:41:46.000Z',
u'creator': {u'displayName': u'*********',
u'email': u'*************'},
u'end': {u'date': u'2014-08-20'},
u'etag': u'"2816263412782000"',
u'hangoutLink': u'******************',
u'htmlLink': u'********************',
u'iCalUID': u'********************',
u'id': u'v28jdhl0ikm9c2eb859f6rhj3k',
u'kind': u'calendar#event',
u'organizer': {u'displayName': u'Test Schedule',
u'email': u'*******************8',
u'self': True},
u'reminders': {u'useDefault': True},
u'sequence': 0,
u'start': {u'date': u'2014-08-18'},
u'status': u'confirmed',
u'summary': u'TESTING THINGS',
u'updated': u'2014-08-15T19:41:46.391Z'}

Solution

  • The attendees are supposed to be a list of dictionaries, such that:

    {'attendees':{'email':'*********@gmail.com'}
    

    is supposed to be:

    {'attendees':[{'email':'*********@gmail.com'}]
    

    I had not noticed the brackets in the documentation, and the former did not raise an error. Hope this helps someone from pulling their hair out.