1

I am writing a calendar integration and using the Google Calendar api and Outlook Graph api to sync calendar events. I am receiving webhook notifications as changes are made to events, so I need a way to identify that an event in Google and an event in Outlook are the same (or different) events. Theoretically, this should be done with the iCalUId.

However, when I create an event in Google that has an Outlook attendee, the event created in Outlook does not have the same iCalUId as the event in Google.

I created a work-around for this by reading the iCalUId from the attachment sent by Google to Outlook. However, the Outlook event itself still has a different iCalUId than the Google event, which makes it difficult to process future updates.

Conceptually, Outlook is able to update an event (and show it updated on the calendar) when it is updated by Google. So Outlook must be storing some reference to the Google event.

Does anyone know what that reference is and if it is accessible through the Graph API/SDK?

UPDATE Here is the code I am using to save an event in Google using the Google API/SDK:

 var service = await GoogleAuthenticationProvider.GetCalendarService(CALENDAR_CLIENT_ID, CALENDAR_CLIENT_SECRET, CALENDAR_ACCESS_SCOPES, Person.CalendarRefreshToken).ConfigureAwait(false);

        var timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(Person.TimeZone);

        //in google, having the organizer as an attendee causes the organizer to receive notification emails from google- which we don't want, so remove him/her from the attendees
        var attendees = Event.Attendees.Where(a => a.Value != Event.OrganizerEmail);

        var tmpEvent = new Google.Apis.Calendar.v3.Data.Event
        {
            Id = ExternalID.IsNullOrEmptyExtension() ? 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,
            Recurrence = Event.RecurrenceRule.IsNullOrEmptyExtension() ? new List<string> { } : new List<string> { "RRULE:" + Event.RecurrenceRule }
        };

        var savedEvent = new Google.Apis.Calendar.v3.Data.Event { };

        if (ExternalID.IsNullOrEmptyExtension())
        {
            EventsResource.InsertRequest insertRequest = service.Events.Insert(tmpEvent, GOOGLE_PRIMARY_CALENDARID);

            insertRequest.SendUpdates = EventsResource.InsertRequest.SendUpdatesEnum.All;

            savedEvent = await insertRequest.ExecuteAsync().ConfigureAwait(false);
        }
        else
        {
            var updateRequest = service.Events.Update(tmpEvent, GOOGLE_PRIMARY_CALENDARID, ExternalID);
            updateRequest.SendUpdates = EventsResource.UpdateRequest.SendUpdatesEnum.All;

            savedEvent = await updateRequest.ExecuteAsync().ConfigureAwait(false);
        }
Spencer Gray
  • 111
  • 5
  • Could you show the code about what have you tried? – Raserhin Aug 12 '20 at 15:47
  • I updated the post with the code I am using to save an event in Google. Google is generating an iCalUId and sending the invitation to Outlook. When Outlook creates the event, it will have a different iCalUId (which is the issue). Thanks! – Spencer Gray Aug 12 '20 at 17:14
  • Have you look into CalDAV? I think is the thing you are trying to look for. A way to manage a calendar across multiple platforms that takes care of attendees, timezones, etc See if this could fit you – Raserhin Aug 13 '20 at 14:51
  • Thanks for the info! I see where google [supports it](https://developers.google.com/calendar/caldav/v2/guide) but I don't see where Outlook fully supports it. Also, do you know if it supports webhooks? Thanks again! – Spencer Gray Aug 13 '20 at 18:01
  • You could take a look at [this post](https://support.microsoft.com/en-us/office/see-your-google-calendar-in-outlook-c1dab514-0ad4-4811-824a-7d02c5e77126?ui=en-us&rs=en-us&ad=us), explaining how to sync calendars and Outlook. Also I don't know if Outlook support webhooks, Google in the other hand supports them for a lot of usage case. – Raserhin Aug 20 '20 at 08:38

0 Answers0