Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why am I seeing "reference error: "Calendar" is not defined" when I run a Google Spreadsheet API script?

I made a working bound script in a clone of my original Google Spreadsheet, put together over a course of several days.

I then copied my formula to a new spreadsheet.

Suddenly, even though I don't think I made any changes to any relevant code, I'm seeing "reference error: "Calendar" is not defined google API."

I have a lot of code so it would be difficult to paste it all, but the relevant section is here:

var start = (passed as argument to function);
  var end = (passed as argument to function);
  var calendarId = 'redacted'//source calendar 
  var optionalArgs = {
    timeMin: start.toISOString(),
    timeMax: end.toISOString(),
    showDeleted: false,
    singleEvents: true,
    maxResults: null,
    orderBy: 'startTime'
  };
  var response = Calendar.Events.list(calendarId, optionalArgs);
like image 411
Dr.Queso Avatar asked Mar 14 '16 07:03

Dr.Queso


1 Answers

This took me way too long to get through, so dear person of the future, if I've saved you a few minutes, my struggles will be worthwhile.

Calendar API has to be turned on for Calendar.Events.list to work.

In your script's menu, select "Resources" then "Advanced Google Services." You will see a list of APIs with switches.

To use the API for another service, you must turn it on both here and in your Google Developers Console (just follow the link at the bottom of the dialogue window).

Also, I had sort of assumed that in the Google Developers Console, once an API was turned on, it was turned on for you as a user, but there is a unique console for each project, which is what you're taken to when you follow the link. You have to turn it on again for each additional project.

like image 174
Dr.Queso Avatar answered Sep 30 '22 18:09

Dr.Queso