json - Python client library for Google Calendar API v3 insert event throwing "Missing end time" error -


i have searched web solution seemed 1 couldn't solve issue.

so python code looks like:

class reminderdate(object):     def __init__(self, datetimestring, timezone="australia/sydney"):         self.datetime = datetimestring         self.timezone = timezone class reminderformat(object):     def __init__(self, usedefault=false):         self.usedefault = usedefault         self.overrides = [{"method":"email", "minutes":15}] class reminderdata(object):     def __init__(self, reminder, datefrom=none, dateto=none, datevalue=none):         self.summary = reminder         self.start = reminderdate(datefrom)         self.end = reminderdate(dateto)         self.reminders = reminderformat()  def save_event_to_google_calendar(self, reminder_data):         credentials = self.get_credentials()         service = build('calendar', 'v3', http=credentials.authorize(http()))         event = json.dumps(reminder_data, default=lambda o: o.__dict__)         print (event)         created_event = service.events().insert(calendarid=calendar_id, body=str(event), sendnotifications=true).execute()         pp.pprint(created_event) 

and produces hence print(event) outputs json below:

{"start": {"timezone": "australia/sydney",             "datetime": "2015-04-26t18:45:00+10:00"},   "end": {"timezone": "australia/sydney",           "datetime": "2015-04-26t19:00:00.000+10:00"},   "reminders": {"overrides": [{"minutes": 15, "method": "email"}],                 "usedefault": false},   "summary": "do grocery shopping"} 

and following error:

    file "/usr/local/lib/python2.7/dist-packages/googleapiclient/http.py", line 729, in execute         raise httperror(resp, content, uri=self.uri)     googleapiclient.errors.httperror:  <httperror 400 when requesting https://www.googleapis.com/calendar/v3/calendars/myemail%40gmail.com/events?alt=json&sendnotifications=true  returned "missing end time."> 

i dont understand. have "end" time in json. missing here ?

i have tried posting same json via google developer console https://developers.google.com/google-apps/calendar/v3/reference/events/insert , works. fails python client library :( (described above)


[edit] solution found

the issue had converted python object json "string" , that's supplying opposed json "object" expected api. right code:

json_event = json.loads(event) created_event = service.events().insert(calendarid=calendar_id, body=json_event, sendnotifications=true).execute() 

try adding:

httplib2.debuglevel = 4 

just before api call. allow see exact body events.insert() request sending. compare body produced api explorer , should have answer.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -