I am trying to get free-busy information from Google Calendar using the NodeJS API as listed here https://developers.google.com/google-apps/calendar/v3/reference/freebusy/query. The problem is that the only error response I get is 'invalid request'. When I run it with the Google's Try It tool, i am able to get response though. I know that I am getting an authorized client. What can I do to troubleshoot this further?
function getAvail(auth, dateTimeRange, calID) {
var deferred = Q.defer(); // get a new deferral
calendar.freebusy.query({
auth: auth,
items: [{id: calID}],
timeMin: (dateTimeRange.start).toISOString(),
timeMax: (dateTimeRange.end).toISOString(),
}, function(err, response) {
console.log('Response from the Calendar service: ' + response);
if (err) {
console.log('There was an error contacting the Calendar service: ' + err);
deferred.reject(); // deferred reject here
return;
}
var events = response[calID]['busy'];
if (events.length == 0) {
console.log('No upcoming events found.');
} else {
console.log('busy in here...');
}
deferred.resolve(response); // deferred resolve here
});
return deferred.promise; // return a promise
}