3

I am getting a lot of errors related to ErrorIrresolvableConflict response code when trying to create an event

Stack Trace -    at Microsoft.OData.ProxyExtensions.DataServiceContextWrapper.<SaveChangesAsync>d__5e.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Office365CalendarProviderBL.<>c__DisplayClass7_0.<<CreateCalendarEvent>b__0>d.MoveNext() - Inner Exception - Microsoft.OData.Client.DataServiceRequestException: An error occurred while processing this request. ---> Microsoft.OData.Client.DataServiceClientException: {"error":{"code":"ErrorIrresolvableConflict","message":"The send or update operation could not be performed because the change key passed in the request does not match the current change key for the item."}}
   --- End of inner exception stack trace ---
   at Microsoft.OData.Client.SaveResult.HandleResponse()
   at Microsoft.OData.Client.BaseSaveResult.EndRequest()
   at Microsoft.OData.Client.DataServiceContext.EndSaveChanges(IAsyncResult asyncResult)
   at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.OData.ProxyExtensions.DataServiceContextWrapper.<SaveChangesAsync>d__5e.MoveNext()

I am getting this message with this exception - The send or update operation could not be performed because the change key passed in the request does not match the current change key for the item.

  1. Please explain what is a change key and how it works ?
  2. I am getting these exceptions only from yesterday and hasn't changed any code. Do I need to update anything at my end or am I missing anything ?

I am using V1 DLL - https://api.office.com/discovery/v1.0/me/ ProxyExtension Version - 23

Code:-

// In this method, we are populating event properties later used to create event on calendar. Please verify if I am missing any important property here
private Event CreateCalEventObj(CalendarMeetingBL meeting, string location, meetingAdditionalDataBL data)
{
    Event calEvent = new Event();
    try
    {
        calEvent.Subject = WEB.HttpUtility.HtmlDecode(meeting.MeetingName);
        calEvent.ShowAs = FreeBusyStatus.Busy;
        if (meeting.EventAlarmInMinutes == -1)
            meeting.EventAlarmInMinutes = null;
        calEvent.Reminder = meeting.EventAlarmInMinutes;
        calEvent.Start = meeting.StartTime;
        calEvent.End = meeting.EndTime;
        calEvent.StartTimeZone = meeting.TimeZoneString;
        calEvent.EndTimeZone = meeting.TimeZoneString;

        if (!string.IsNullOrEmpty(location) && location.Length <= 500)
        {
            calEvent.Location = new Microsoft.Office365.OutlookServices.Location()
            {
                DisplayName = CommonBL.FixLineBreakForGooglelocation(WEB.HttpUtility.HtmlDecode(location.Replace("\n", " ")))
            };
        }
        else if (!string.IsNullOrEmpty(data.Phone))
        {
            calEvent.Location = new Microsoft.Office365.OutlookServices.Location()
            {
                DisplayName = "Phone: " + CommonBL.FixLineBreakForGooglelocation(WEB.HttpUtility.HtmlDecode(data.Phone))
            };
        }
        else if (!string.IsNullOrEmpty(data.MobileNumber))
        {
            calEvent.Location = new Microsoft.Office365.OutlookServices.Location()
            {
                DisplayName = "Mobile: " + CommonBL.FixLineBreakForGooglelocation(WEB.HttpUtility.HtmlDecode(data.MobileNumber))
            };
        }
        calEvent.Body = new ItemBody()
        {
            Content = CommonBL.RevertLineBreakPlaceHolder((WEB.HttpUtility.HtmlDecode(meeting.MeetingDetails.Replace(@"\\\", "\\"))))
        };
    }
    catch (Exception ex)
    {
        BLFactory.CurrentInstance.LoggingBLObj.InsertLog("Insert logging here");
        calEvent = null;
    }
    return calEvent;
}

// In this method we are creating event on calendar.
private string CreateCalendarEvent(CalendarMeetingBL meeting, List<ParticipantBL> invitees, string username, string calendarId, OutlookServicesClient service, string location, meetingAdditionalDataBL data, string meetingId = "-1")
{
    var taskCreateMeeting = Task<string>.Run(
            async () =>
            {
                Event calEvent = CreateCalEventObj(meeting, location, data);
                if (calEvent != null)
                {
                    try
                    {
                        //Add invitees to the event
                        foreach (ParticipantBL inviteeItem in invitees)
                        {
                            if (!inviteeItem.IsAdditional)
                            {
                                calEvent.Attendees.Add(new Attendee()
                                {
                                    EmailAddress = new EmailAddress()
                                    {
                                        Address = inviteeItem.Email.Replace("&#39;", "'"),
                                        Name = inviteeItem.Name
                                    },
                                    Type = AttendeeType.Required,
                                    Status = new ResponseStatus()
                                    {
                                        Response = ResponseType.Accepted,
                                        Time = DateTime.Now
                                    }
                                });
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        BLFactory.CurrentInstance.LoggingBLObj.InsertLog(meeting.MeetingId, username, "Locally User ID is Meeting id AND email is username - Scheduling Logging Exception 3 - Stack Trace - " + ex.StackTrace + " - Inner Exception - " + ex.InnerException + " - meetingObjValues - " + meetingObjValues + " - meetingAdditionalDataObjValues - " + meetingAdditionalDataObjValues + " -  username - " + username + " - calendarId - " + calendarId + " - location - " + location + " - meetingId - " + meetingId, meeting.MeetingId);
                        return "-1";
                    }

                    try
                    {

                        var providerDefault = (String.IsNullOrEmpty(calendarId) ? service.Me.Events : service.Me.Calendars[calendarId].Events);
                        await providerDefault.AddEventAsync(calEvent);          // We are getting Exception here but Event is created in calendar                     
                        return calEvent.Id;                                     // Event object is not updated after exception
                    }
                    catch (Exception ex)
                    {
                        BLFactory.CurrentInstance.LoggingBLObj.InsertLog("Insert exception logging here");
                        return "-1";
                    }
                }
                else
                    return "-1";
            }
        );
    Task.WaitAll(taskCreateMeeting);
    string id = taskCreateMeeting.Result;
    return id;
}

The exception we are getting is of type Microsoft.OData.Client.DataServiceRequestException but it is not caught under the dedicated catch block

                catch (Microsoft.OData.Client.DataServiceRequestException ex)
                {
                    BLFactory.CurrentInstance.LoggingBLObj.InsertLog("Insert logging here");
                    return "-1";
                }

Let me know if anything else is required Thanks in Advance.

Harsh Vats
  • 138
  • 1
  • 9
  • Is **calendarId** null or empty in the code `var providerDefault = (String.IsNullOrEmpty(calendarId) ? service.Me.Events : service.Me.Calendars[calendarId].Events);`? I also suggest that you track the error detail using the **Fiddler** to see the detail error. – Fei Xue Jul 08 '16 at 06:27
  • It seems the issue has been fixed. Take a look [here](https://stackoverflow.com/questions/58663396/getting-error-code-errorirresolvableconflict-responses-when-trying-to-create-e) – Dmitry Dolotovskikh Jan 09 '20 at 10:21

1 Answers1

1

This is not directly related to OData - we have seen the same thing with EWS. We just found the underlying race condition inside of Exchange code that was causing this and one of our devs just checked in a fix for this. As such, it should start rolling out in production soon.

There is nothing wrong with your code that would be causing this for a new item.

  • Thanks David for the update. Can you please look into another issue as well ? http://stackoverflow.com/questions/41478331/office-365-default-calendars-id-changes-automatically This issue is on a higher priority for us. – Harsh Vats Feb 06 '17 at 07:26
  • I've just started experiencing this, but with updates to message categories. It seems to have started on the 17th March 2017 for us. – Rexx Magnus Mar 20 '17 at 09:38
  • Hello David, could you, please, tell us to which version of Exchange this bug affects and on which version it is fixed? Thanks in advance. – Pau Apr 27 '18 at 12:49
  • I'm not sure which build this was fixed in, but it has certainly been deployed world wide that this point. Let me know if you are still seeing this behavior. – David Sterling - MSFT May 15 '18 at 15:49
  • 1
    Hi @DavidSterling-MSFT, I am wondering if a similar issue is currently observed? We are getting this exact `ErrorIrresolvableConflict` intermittently when creating events with attendees through Outlook REST api (v2.0). Started happening on Oct 28 and we can't get a confirmation if this is a known issue, other than this article, which seems tangentially related: https://support.office.com/en-us/article/the-operation-cannot-be-performed-because-the-item-has-changed-74c99323-8a0d-4d45-ad32-e462e215a82a – lior Nov 01 '19 at 02:58
  • 1
    I am also seeing this kind of behaviour happening in my application when creating events with attendees so I guess this means the race condition indicated in the thread came back to live. – Antonio Acevedo Nov 01 '19 at 15:40
  • @lior, yes it looks it's the same issue and related to the article you provided. It's still there, we're getting such errors a couple of times a day when calling Graph API. It's a shame it's not mentioned anywhere it happens. What's worse, sometimes when we get an error, the event is eventually created, but after the error we retry, resulting in duplicated events... – Krzysztof Wolny Nov 28 '19 at 10:58
  • @DavidSterling-MSFT any idea when the issue will be resolved? It's still there and affecting usage of API. Workarounds mentioned for Outlook are not applicable when using API: https://support.microsoft.com/en-us/help/4502145/error-when-a-delegate-create-skype-or-teams-meeting-in-outlook – Krzysztof Wolny Nov 28 '19 at 11:11