Search code examples
google-calendar-api

How to update "Going? Yes/No/Maybe" in Google calendar via API?


I am using Google Calendar API to work with events. For example, someone create an event and invites me. So, at the bottom of the event's detail I have 3 options of "Going": YES/NO/MAYBE. My question is how can I answer this by API?

I tried to use an UPDATE request, but it will create a new version of the event in my own calendar instead.

calendar.events.update(
  {
    calendarId: "primary",
    eventId: event.id,
    resource: {
      start: {
        dateTime: event.start.dateTime,
      },
      end: {
        dateTime: event.end.dateTime,
      },
      attendees: [
        {
          email: "myemail@gmail.com",
          responseStatus: "accepted",
        },
      ],
    },
  },
  (err, response) => {
  }
)

enter image description here


Solution

  • For example, how about using patch instead of update as follows?

    Modified script:

    calendar.events.patch(
      {
        calendarId: "primary",
        eventId: event.id,
        resource: {
          attendees: [
            {
              email: "myemail@gmail.com",
              responseStatus: "accepted",
            },
          ],
        },
      },
      (err, response) => {
      }
    )
    

    Reference: