Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to "Add guest" to event via google calendar API?

could you please give me a hint on how to share a single event via google calendar api?

That is I'd like to invite other users to see the event programmatically without sharing the whole calendar. To mimic the "Add guests" UI action The google calendar Add guests

like image 643
Igor Avatar asked Dec 12 '22 23:12

Igor


1 Answers

As Claudio mentioned, you need to use the Google Calendar Advanced API for this.

You'll want to use a patch because you don't want to replace all the other data on the calendar invite. However, even in the case of patch, since the attendees lives in an array, if you attempt to pass a patch such as this:

{
  attendees: [ { email: "[email protected]"} ]
}

... it'll replace all old invitees (i.e. it'll remove anyone that was on the invite before you called patch). To fix this, you must first get the current invitees, add a new person to the array, and then send a patch.

You can see a detailed example of this in this answer which also explains how to use Google Apps Scripting to ensure an email is sent to the user when adding them to a calendar event (see the addGuestAndSendEmail() method in that post).

like image 148
Senseful Avatar answered Jan 31 '23 22:01

Senseful