1
votes

I was wondering if anyone knew how to notifiy attendees upon event creation in google calendar. When I create the event manualy, I can send an event as I wish. But when I create the event using the api with the javascript client library. I do not receive email notifications.

Here is my code for creation :

var request = gapi.client.calendar.events.insert({
    'calendarId': '***@***.com',
    'resource': resource
});
request.execute(function() {
});

My resource variable is already defined and the event is added successfuly to the calendar, but no attendees receive any invitations. And if I go into the event on the calendar after creating it, the attendees are there.

Is there anything I am missing in the request to make it so that the attendees receive notifications upon the creation.

4

4 Answers

5
votes

The attendees array has a responseStatus that you can set to: "needsAction" - The attendee has not responded to the invitation. "declined" - The attendee has declined the invitation. "tentative" - The attendee has tentatively accepted the invitation. "accepted" - The attendee has accepted the invitation.

var request = gapi.client.calendar.events.insert({
  'calendarId': '***@***.com',
  'resource': resource,
  'attendees': [{'email':'[email protected]','responseStatus':'needsAction'}]
  }
});
request.execute(function() {
});
2
votes

You have to set parameter "sendNotifications" to true. Here you can see that this is set to false at default. https://developers.google.com/google-apps/calendar/v3/reference/events/insert

1
votes

On the iOS version of the API, the sendNotifications property is on the request object - so you need to create the request first, then set the sendNotifications property before executing it. Look at the request object, see if the Java API is similar (likely).

e.g. request.sendNotifications = true;

before calling request.execute()

1
votes

In the Java client there's the insert method of the event, and then there's the setSendNotifications method. You'll have to do something like this:

Event createdEvent = calendario.events().insert("[email protected]", event).setSendNotifications(true).execute();