Reputation: 21
while trying to insert and event i continously getting the same error although i try to use different time zone and even copy pasted the the code snippet provided Events:insert.
The error i am getting is :
<HttpError 400 when requesting https://www.googleapis.com/calendar/v3/calendars/primary/events?alt=json returned "Missing end time.". Details: "Missing end time.">
The code i am using to create the event is :
event = {
'summary': data['summary'],
'description': data['description'],
'start': {
'dateTime': data['start_time'],
'timeZone': 'ASIA/KOLKATA',
},
'end': {
'dateTime': data['end_time'],
'timeZone': 'ASIA/KOLKATA',
},
'recurrence': [
'RRULE:FREQ=DAILY;COUNT=2'
],
'attendees': [
{'email': '[email protected]'},
{'email': '[email protected]'},
],
'reminders': {
'useDefault': False,
'overrides': [
{'method': 'email', 'minutes': 24 * 60},
{'method': 'popup', 'minutes': 10},
],
}
}
created_event = service.events().insert(calendarId='primary', body=event).execute()
I tried converting to RFC3339 but same error .
Note - i am getting data from a POST request through a serializer.
Upvotes: 0
Views: 492
Reputation: 21
This error occur when we dont pass the correct format in the body section of the insert fucntion.
service.events().insert(calendarId='primary',sendNotifications=True, body=event).execute()
I found out that i was passing the datetime object into datetime keyword for event whereas we have to first convert the datetime into standard RFC339 as specififed under authorization section here and then convert it to string to be passed into event body.
To convert Django models.datetime object into RFC3339 string do this:
str(date.isoformat('T'))
Upvotes: 1