none
Error while setting Appointment.Recurrence.EndDate using EWS Managed API RRS feed

  • Question

  • Hi All,

    I hope someone can help me with an issue I've been facing while ending meetings on my calendar programmatically. I've tried out 2 cases, 1 of which works and 1 doesn't. The code block which carries out the operation is as follows (The Subject that I check for changes depending on the meeting I want to end, and the entire section is within a try-catch block).

    target = Appointment.BindToRecurringMaster(service, result.Id, new PropertySet(AppointmentSchema.Organizer, AppointmentSchema.Subject, AppointmentSchema.Location, AppointmentSchema.Recurrence, AppointmentSchema.RequiredAttendees, AppointmentSchema.OptionalAttendees, AppointmentSchema.AppointmentType));
    
    if (target.Subject.Equals("Testing Modified"))
    {
        target.Recurrence.EndDate = DateTime.Today;
        target.Update(ConflictResolutionMode.AlwaysOverwrite, SendInvitationsOrCancellationsMode.SendToNone);
    }

    Case 1: Ending a meeting in my calendar, where I am the organizer.

    This proceeds without any error. All occurrences of the meeting from DateTime.Today onwards is removed from my calendar, and reflected in Outlook. It does remain on the calendars of other attendees, this is by design. The following is the request to set an EndDate and the corresponding response:

    <Trace Tag="EwsRequest" Tid="1" Time="2013-08-28 07:27:05Z" Version="15.00.0516.014">
      <?xml version="1.0" encoding="utf-8"?>
      <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
        <soap:Header>
          <t:RequestServerVersion Version="Exchange2010_SP2" />
        </soap:Header>
        <soap:Body>
          <m:UpdateItem ConflictResolution="AlwaysOverwrite" SendMeetingInvitationsOrCancellations="SendToNone">
            <m:ItemChanges>
              <t:ItemChange>
                <t:ItemId Id="AAMkADdiMzY1ZWMwLTRkY2YtNDhiNi05OWY3LTA1OTJlMWY1OGNjNQBGAAAAAADlthcp0nAmSJHp0KzsDecrBwAQPHeHSGwtR6J6/hI0H+gZAAAA/CwVAABtryIZ/QTbT6f5oUZQX9AxAAUvHYQyAAA=" ChangeKey="DwAAABQAAAASQRS5pRnpSpEuDS9HteUWAADkaA==" />
                <t:Updates>
                  <t:SetItemField>
                    <t:FieldURI FieldURI="calendar:Recurrence" />
                    <t:CalendarItem>
                      <t:Recurrence>
                        <t:WeeklyRecurrence>
                          <t:Interval>1</t:Interval>
                          <t:DaysOfWeek>Tuesday</t:DaysOfWeek>
                          <t:FirstDayOfWeek>Sunday</t:FirstDayOfWeek>
                        </t:WeeklyRecurrence>
                        <t:EndDateRecurrence>
                          <t:StartDate>2013-08-27</t:StartDate>
                          <t:EndDate>2013-08-28+05:30</t:EndDate>
                        </t:EndDateRecurrence>
                      </t:Recurrence>
                    </t:CalendarItem>
                  </t:SetItemField>
                </t:Updates>
              </t:ItemChange>
            </m:ItemChanges>
          </m:UpdateItem>
        </soap:Body>
      </soap:Envelope>
    </Trace>
    <Trace Tag="EwsResponse" Tid="1" Time="2013-08-28 07:27:07Z" Version="15.00.0516.014">
      <?xml version="1.0" encoding="utf-8"?>
      <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
        <s:Header>
          <h:ServerVersionInfo MajorVersion="14" MinorVersion="3" MajorBuildNumber="146" MinorBuildNumber="0" Version="Exchange2010_SP2" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
        </s:Header>
        <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
          <m:UpdateItemResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
            <m:ResponseMessages>
              <m:UpdateItemResponseMessage ResponseClass="Success">
                <m:ResponseCode>NoError</m:ResponseCode>
                <m:Items>
                  <t:CalendarItem>
                    <t:ItemId Id="AAMkADdiMzY1ZWMwLTRkY2YtNDhiNi05OWY3LTA1OTJlMWY1OGNjNQBGAAAAAADlthcp0nAmSJHp0KzsDecrBwAQPHeHSGwtR6J6/hI0H+gZAAAA/CwVAABtryIZ/QTbT6f5oUZQX9AxAAUvHYQyAAA=" ChangeKey="DwAAABYAAAAQPHeHSGwtR6J6/hI0H+gZAAABAHiO" />
                  </t:CalendarItem>
                </m:Items>
                <m:ConflictResults>
                  <t:Count>0</t:Count>
                </m:ConflictResults>
              </m:UpdateItemResponseMessage>
            </m:ResponseMessages>
          </m:UpdateItemResponse>
        </s:Body>
      </s:Envelope>
    </Trace>

    As you can see, no errors in the response.

    Case 2: Ending a meeting in my calendar, where someone else is the organizer.

    Same code, same everything (except the Subject to check for, of course), but it gives a ServiceResponseException: Set action is invalid for property. (Where I'm assuming the property is Recurrence.EndDate). The following is the request to set an EndDate and the corresponding response:

    <Trace Tag="EwsRequest" Tid="1" Time="2013-08-28 07:22:21Z" Version="15.00.0516.014">
      <?xml version="1.0" encoding="utf-8"?>
      <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
        <soap:Header>
          <t:RequestServerVersion Version="Exchange2010_SP2" />
        </soap:Header>
        <soap:Body>
          <m:UpdateItem ConflictResolution="AlwaysOverwrite" SendMeetingInvitationsOrCancellations="SendToNone">
            <m:ItemChanges>
              <t:ItemChange>
                <t:ItemId Id="AAMkADdiMzY1ZWMwLTRkY2YtNDhiNi05OWY3LTA1OTJlMWY1OGNjNQBGAAAAAADlthcp0nAmSJHp0KzsDecrBwAQPHeHSGwtR6J6/hI0H+gZAAAA/CwVAABtryIZ/QTbT6f5oUZQX9AxAAUvHYQuAAA=" ChangeKey="DwAAABYAAAAQPHeHSGwtR6J6/hI0H+gZAAABAHf6" />
                <t:Updates>
                  <t:SetItemField>
                    <t:FieldURI FieldURI="calendar:Recurrence" />
                    <t:CalendarItem>
                      <t:Recurrence>
                        <t:WeeklyRecurrence>
                          <t:Interval>1</t:Interval>
                          <t:DaysOfWeek>Monday</t:DaysOfWeek>
                          <t:FirstDayOfWeek>Sunday</t:FirstDayOfWeek>
                        </t:WeeklyRecurrence>
                        <t:EndDateRecurrence>
                          <t:StartDate>2013-08-26</t:StartDate>
                          <t:EndDate>2013-08-28+05:30</t:EndDate>
                        </t:EndDateRecurrence>
                      </t:Recurrence>
                    </t:CalendarItem>
                  </t:SetItemField>
                </t:Updates>
              </t:ItemChange>
            </m:ItemChanges>
          </m:UpdateItem>
        </soap:Body>
      </soap:Envelope>
    </Trace>
    <Trace Tag="EwsResponse" Tid="1" Time="2013-08-28 07:22:22Z" Version="15.00.0516.014">
      <?xml version="1.0" encoding="utf-8"?>
      <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
        <s:Header>
          <h:ServerVersionInfo MajorVersion="14" MinorVersion="3" MajorBuildNumber="146" MinorBuildNumber="0" Version="Exchange2010_SP2" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
        </s:Header>
        <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
          <m:UpdateItemResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
            <m:ResponseMessages>
              <m:UpdateItemResponseMessage ResponseClass="Error">
                <m:MessageText>Set action is invalid for property.</m:MessageText>
                <m:ResponseCode>ErrorInvalidPropertySet</m:ResponseCode>
                <m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>
                <m:MessageXml>
                  <t:FieldURI FieldURI="calendar:Recurrence" />
                </m:MessageXml>
                <m:Items />
              </m:UpdateItemResponseMessage>
            </m:ResponseMessages>
          </m:UpdateItemResponse>
        </s:Body>
      </s:Envelope>
    </Trace>

    What could be the reason for this? I'm only making changes to objects in my calendar with my credentials, so permissions shouldn't be an issue - I don't even want changes reflecting on others' calendars. I was able to perform this operation using Outlook (changing the EndDate of a meeting in my calendar where someone else is the organizer), it worked as expected. I assume that everything that can be done using Outlook, can be done using EWS Managed API – please correct me if I’m wrong.

    Here's another weird case - In case 2, instead of changing Recurrence.EndDate, I tried changing the Subject, and that works just fine! Again, the change in Subject is reflecting only on my calendar. 

    Please let me know any solutions or workarounds to this issue, as it seems to be very inconsistent behavior and is a dealbreaker.

    Thanks,

    Shashank

    Wednesday, August 28, 2013 2:42 PM

All replies

  • Updating an Appointment's Start ,End ,Attendees etc when your not the Organizer/Owner of the appointment is not a valid operation for an attendee (the business logic in EWS\Exchange won't allow this). If you no longer want the appointment then you should delete it. Otherwise the only way of updating it in a supported way is to create a Calender update message and Accept the update http://msdn.microsoft.com/en-us/library/dd633648(v=exchg.80).aspx.

    A simple way to test if something that your doing is valid is to try doing that same thing in Outlook or OWA.

    Cheers
    Glen

    Thursday, August 29, 2013 4:30 AM
  • Thanks for your response, Glen. I'd like to address a few of the points you brought up:

    Updating an Appointment's Start ,End ,Attendees etc when your not the Organizer/Owner of the appointment is not a valid operation for an attendee (the business logic in EWS\Exchange won't allow this). A simple way to test if something that your doing is valid is to try doing that same thing in Outlook or OWA.

    That's the thing - I tried the same operation in Outlook for the same meeting (changing the End Date of a meeting where I'm not the organizer), and it allowed the operation. Hence, why shouldn't EWSMA allow it? 

    If you no longer want the appointment then you should delete it. 

    The reason I can't delete/cancel the meeting is that I'll lose all past history of the meeting from my calendar, including associated minutes, attachments etc. Ending a meeting, on the other hand, will only remove future occurrences of the meeting.

    Otherwise the only way of updating it in a supported way is to create a Calender update message and Accept the update.

    If I understand correctly, you're suggesting that I create a calendar update message as the organizer of the meeting, and send it to all attendees (please correct me if I'm wrong).  The issue here is that the organizer is no longer a member of our organization and has no mailbox - therefore we can't create meeting update requests on behalf of the user.

    I hope this sheds more light on the problem at hand.

    Regards,

    Shashank

    Thursday, August 29, 2013 5:56 AM
  • One more point I'd like to emphasize, Glen: I'm trying to end the meeting in my calendar only so that the time slots are freed up. I do not want the change to be notified (i.e mail to be sent) to neither organizer nor other attendees. Outlook allows me to do this and I hope it can be done using EWS as well.

    Regards,

    Shashank

    Thursday, August 29, 2013 7:28 AM
  • While Outlook does allow this if you try the same thing in OWA it won't allow this.

    I guess the bottom line is the response your getting back from EWS is telling you that it doesn't allow that property to be updated in that situation because of a Business logic reason (which is why OWA also doesn't allow this either). I'm not 100% sure but I don't think you will be able to override this using the Strong Types in EWS.

    As a workaround using MAPI as Outlook is doing should work okay if its a one off that's probably going to be the easiest method. In EWS you maybe able to workaround this issue by either modifying the Recurrence Extended MAPI properties directly http://msdn.microsoft.com/en-us/library/office/cc979209.aspx and http://msdn.microsoft.com/en-us/library/cc425490(v=exchg.80).aspx . (You could probably create a Meeting Update message manually in EWS and accept that as well).

    Cheers
    Glen

    Friday, August 30, 2013 2:31 AM