Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Google Calendar API's Events.Insert command properly?

Tags:

So I've been using the REST method of invoking Google's API. I need to insert events into a particular calendar whose ID I have. This is the POST request I'm sending:

Address: https://www.googleapis.com/calendar/v3/calendars/{calendarID}/events

Body:

Authorization:  Bearer {access_token} {  "end": {   "dateTime": "2012-08-30T12:30:00",   "timeZone": "America/Chicago"  },  "start": {   "dateTime": "2012-08-30T14:00:00",   "timeZone": "America/Chicago"  },  "summary": "E E 306",  "colorId": "9"  "kind": "calendar#event" } 

And this is the response I keep getting:

{  "error":{   "errors":[    {     "domain":"calendar",     "reason":"timeRangeEmpty",     "message":"The specified time range is empty.",     "locationType":"parameter",     "location":"timeMax"    }   ],   "code":400,   "message":"The specified time range is empty."  } } 

I don't understand what I could possibly be doing wrong. I've entered all necessary data, and it's asking me for a parameter that doesn't even exist for events. I also can't find any documentation out there on this particular problem. Does anyone see something I'm missing?

like image 891
AnonymousJohn Avatar asked Jun 05 '12 04:06

AnonymousJohn


People also ask

How do I automatically add events to Google Calendar?

In Gmail settings, turn on Smart features and personalization. Learn how to turn on Smart features and personalization in Gmail. In Google Calendar settings, go to Events from Gmail, and check the box next to Show events automatically created by Gmail in my calendar.

How does the Google Calendar API work?

The Google Calendar API enables developers to add full calendar data and functionality into their app using a REST interface, or through one of the client libraries Google offers for languages like Java, Python, PHP, JavaScript, and more.


1 Answers

In the midst of asking this question, I face palmed so hard I think I've done myself brain damage. As it turns out, the reason I couldn't find any documentation on this problem was because of how spectacularly silly it was.

The reason it was giving me such a funny error was because in the copy-pasting I was doing to test, I flipped the start and end times. So, I was telling Google Calendars to enter an event that ended before it started, which generally doesn't end too well.

Long story short, if you get an error referring to the "timeMax" parameter while trying to insert an event, check your start and end times.

like image 110
AnonymousJohn Avatar answered Sep 24 '22 00:09

AnonymousJohn