Spencer Gray
Spencer Gray

Reputation: 121

Google event attendees list not updating on Outlook calendar event

I am writing a calendar integration and using the Google Calendar api and Outlook Graph api to sync calendar events. I am receiving webhooks as changes are made to events, so it is important that events are identical across calendar providers.

When I update the event attendees on a Google event however, an event update is not sent to Outlook attendees. The result is that Outlook attendees do not have an accurate attendee list.

If I change the Title/Description/Time, Google sends an event update and the Google and Outlook events get synced (the Outlook event is updated with the correct attendee list).

I have tried updating fields the user doesn't see (ex: sequence, extended properties) in hopes that the change would trigger an event update from Google but that doesn't seem to work.

Has anyone found a way to trigger a Google event update when attendees are added or removed?

UPDATE: For Outlook users, I create a subscription (using the graph SDK) to each user’s calendar:

var graphClient = await MicrosoftAuthenticationProvider.GetGraphClient(CALENDAR_CLIENT_ID, CALENDAR_CLIENT_SECRET, CALENDAR_REDIRECT_URI, CALENDAR_ACCESS_SCOPES, RefreshToken).ConfigureAwait(false);

var tmpSubscription = new Subscription
{
    ChangeType = WEBHOOK_SUBSCRIPTION_CHANGETYPE,
    NotificationUrl = WEBHOOK_NOTIFICATION_ENDPOINT,
    Resource = WEBHOOK_EVENT_RESOURCE_NAME,
    ExpirationDateTime = maxSubscriptionLength,
    ClientState = clientState
};

var subscription = await graphClient.Subscriptions
                                .Request()
                                .AddAsync(tmpSubscription)
                                .ConfigureAwait(false);

When an Outlook event is updated, my webhook notification endpoint receives a notification from Outlook. This happens successfully when I edit the summary, description, start or end of an event in Google. It does not happen when I add or remove attendees.

To replicate: create an event in Google that has an attendee that uses Outlook. You will see the event in Outlook. Add another attendee to the Google event. Google does not send Outlook an update email (the way it does if the title/time/description changes). The Google and Outlook events attendees are now different.

Upvotes: 0

Views: 387

Answers (1)

Spencer Gray
Spencer Gray

Reputation: 121

I found a work-around:

If I know the attendees have changed, I am changing the description of the event and sending a silent patch request to Google:

            var tmpEvent = new Google.Apis.Calendar.v3.Data.Event
        {                
            Description = Event.Description + "---attendees updated---",              
        };

        //don't send the notification to anyone
        //all attendees will get the notification when we resave the event with the original description
        var patchRequest = service.Events.Patch(tmpEvent, GOOGLE_PRIMARY_CALENDARID, ExternalID);
        patchRequest.SendUpdates = EventsResource.PatchRequest.SendUpdatesEnum.None;

        await patchRequest.ExecuteAsync().ConfigureAwait(false);

For the patch, setting SendUpdates to None means attendees won’t receive a notification about the change, so all calendar events will be updated silently.

Finally, I save the entire event (with the proper description and attendees) and send the updates to all of the attendees:

 var tmpEvent = new Google.Apis.Calendar.v3.Data.Event
        {
            Id = ExternalID == null ? Convert.ToString(Event.ID) : ExternalID,
            Start = new EventDateTime
            {
                DateTime = Event.StartDate,
                TimeZone = GetGoogleTimeZoneFromSystemTimeZone(timeZoneInfo.Id)
            },
            End = new EventDateTime
            {
                DateTime = Event.EndDate,
                TimeZone = GetGoogleTimeZoneFromSystemTimeZone(timeZoneInfo.Id)
            },
            Summary = Event.Title,
            Description = Event.Description,
            Attendees = attendees.Select(a => new EventAttendee
            {
                Email = a.Value,
                ResponseStatus = "accepted"
            }).ToList(),
            GuestsCanInviteOthers = false,
            Location = Event.Location
        };
var updateRequest = service.Events.Update(tmpEvent, GOOGLE_PRIMARY_CALENDARID, ExternalID);
            updateRequest.SendUpdates = EventsResource.UpdateRequest.SendUpdatesEnum.All;

            savedEvent = await updateRequest.ExecuteAsync().ConfigureAwait(false);

This isn't ideal because it requires two calls to Google's API just to properly save the attendees, but on the plus side, attendees are only notified of the change once.

Upvotes: 1

Related Questions