office active-directory adal office365api outlook-restapi office365-restapi

active-directory - rest api office 365



ErrorIrresolvableConflict al crear un evento (1)

Recibo muchos errores relacionados con el código de respuesta ErrorIrresolvableConflict cuando trato de crear un evento

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()

Recibo este mensaje con esta excepción: no se pudo realizar la operación de envío o actualización porque la clave de cambio aprobada en la solicitud no coincide con la clave de cambio actual para el artículo.

  1. Por favor, explica qué es una clave de cambio y cómo funciona?
  2. Recibo estas excepciones solo de ayer y no he cambiado ningún código. ¿Debo actualizar algo de mi lado o me falta algo?

Estoy usando DLL V1 - https://api.office.com/discovery/v1.0/me/ Versión ProxyExtension - 23

Código:-

// 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; }

La excepción que obtenemos es de tipo Microsoft.OData.Client.DataServiceRequestException pero no está atrapada en el bloque catch dedicado

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

Avíseme si se requiere algo más Gracias de antemano.


Esto no está directamente relacionado con OData: hemos visto lo mismo con EWS. Acabamos de encontrar la condición de carrera subyacente dentro del código de Exchange que estaba causando esto y uno de nuestros desarrolladores acaba de marcar una solución para esto. Como tal, debería comenzar a extenderse en producción pronto.

No hay nada de malo con su código que pueda estar causando esto para un nuevo artículo.