I'm trying to follow google's example of adding a event and originally it threw errors because I formatted something wrong but now it's saying the event is being made and linking me to it but it never actually makes the event. The 3rd picture I attached is the result and it has a little popup that says error adding event, the weird thing is that none of my events at all show up on the calendar even though I'm logged into the same account in both cases and only have one calendar. The event never gets added to my calendar I've tried running it multiple times even using different data in the event and same result, it says it adds it but never does. I'm lost any help is greatly appreciated please feel free to ask for more info if you need!
edit: here's my event creation function
def createEvent(summary, start_time, end_time, *args, description='', location='', timeZone='America/New_York'):
credentials = get_credentials()
service = discovery.build('calendar', 'v3', credentials=credentials)
event = {
'summary': summary,
'location': location,
'description': description,
'start': {
'dateTime': start_time,
'timeZone': timeZone,
},
'end': {
'dateTime': end_time,
'timeZone': timeZone,
},
'reminders': {
'useDefault': False,
'overrides': [
# {'method': 'email', 'minutes': 24 * 60},
{'method': 'popup', 'minutes': 10},
],
},
}
for arg in args:
event[arg[0]] = arg[1]
event = service.events().insert(calendarId='primary', body=event).execute()
print ('Event created: %s' % (event.get('htmlLink')))
edit 2: this is how the function is called with an example of the information passed in
googEvent = ['CSC 385 hw', '20-1-31T22:59:59', '20-1-31T23:59:59', 'EC Mylavarapu']
createEvent(googEvent[0], googEvent[1], googEvent[2], description=googEvent[3])
After studying your code I found that you are so close to fixing it. You only need to force the date format into ISO 8601. To accomplish that, I used the following Python methods:
import datetime
…
googEvent = ['CSC 385 hw', datetime.datetime.strptime("31/01/2020 22:59:59",
"%d/%m/%Y %H:%M:%S").isoformat(), datetime.datetime.strptime(
"31/01/2020 23:59:59", "%d/%m/%Y %H:%M:%S").isoformat(), 'EC Mylavarapu']
createEvent(googEvent[0], googEvent[1], googEvent[2], description = googEvent[3])
This is only one way of doing it. Each date is first created from a human readable string using strptime()
and later converted into ISO 8601 with isoformat()
. Please, answer me back if you need further help.
This fixed it, thank you so much for all of your help!