Lydia halls
Lydia halls

Reputation: 682

Google Calendar API Freebusy: query does not retun events separatly

In my google calendar I have events back to back:

When I query Freebusy api it retruns one event: 9 a.m - 15 a.m rather than separate events, Why ?

Client post request:

$.post(
  "url",
  function (result) {
    var events = [];
    result.map((event, i) => {
      item = {};
      item["title"] = "SameTextToDisplay";
      item["start"] = event.start;
      item["end"] = event.end;
      events.push(item);
    });
  }
);

My nodejs server function:

calendar.freebusy.query({
  resource: {
    timeMin: TimeMin,
    timeMax: TimeMax,
   timeZone: "America/New_York",
    items: [
      {
        id: "MyCalendarID"
      }
    ]
  }}, (err, resp) => {
    if (err) return console.log('The API returned an error: ' + err);
  res.send(resp.data.calendars[id]);
   });

Upvotes: 0

Views: 871

Answers (1)

Lydia halls
Lydia halls

Reputation: 682

If you want to have a list of events, use the endpoint event.list rather.

There is an example on how to use the list endpoint with the javascript library in the official documentation.

Upvotes: 1

Related Questions