Reputation: 1940
Heyo, I'm using the google-api-nodejs-client package in my NodeJS project and I'm trying to build my query for calendar events. It's working, but I can't specify the "fields" field.
This returns five complete calendar events:
client.calendar.events.list({
calendarId: gcal_id,
maxResults: 5
})
.withAuthClient(authClient)
.execute(function(err, calendar) {
if (err)
console.log(err);
else
console.log(calendar);
});
But this returns nothing:
client.calendar.events.list({
calendarId: gcal_id,
maxResults: 5,
fields: {
items: ["end","start","status","summary"]
}
})
.withAuthClient(authClient)
.execute(function(err, calendar) {
if (err)
console.log(err);
else
console.log(calendar);
});
I've also tried:
fields: {
items: "end,start,status,summary"
}
Based on the Google Calendar V3 API, I should be able to make a query like this: https://www.googleapis.com/calendar/v3/calendars/gcal_id.google.com/events?maxResults=5&fields=items(end%2Cstart%2Cstatus%2Csummary)&key={YOUR_API_KEY}
I'm not sure how to specify the "fields=items(end%2Cstart%2Cstatus%2Csummary)" portion of the URL, but I've tested it in Google's API Explorer and it works, so I know I'm doing something wrong in the JavaScript.
Any help would be much appreciated. For now I think I'll just clean up the response I get from the first code snippet.
Upvotes: 1
Views: 2473
Reputation: 1940
Well, I figured it out. It should be one string.
fields: "items(end,start,status,summary)"
Upvotes: 5