I'm trying to add a new calendar exception to a specific resource using CSOM.
However, when trying to update the resource, I'm getting a PJClientCallableException: CalendarExceptionConflict
, which according to this, seems to occur when there's a conflict in the calendar exceptions.
Here's a piece of my code:
var creationInfo = new CalendarExceptionCreationInformation();
creationInfo.Name = "Vacaciones CSOM";
// Specify (¿optional?) properties.
creationInfo.Start = DateTime.Today;
creationInfo.Finish = DateTime.Today.AddDays(5);
var resourceId = "XXX";
var resource = projContext.EnterpriseResources.GetById(resourceId);
projContext.Load(resource);
projContext.Load(resource.ResourceCalendarExceptions);
projContext.ExecuteQuery();
// Add the calendar exception to the collection.
resource.ResourceCalendarExceptions.Add(creationInfo);
// Submit the request to update the collection on the server
projContext.EnterpriseResources.Update();
projContext.ExecuteQuery();
Any advise?