outlookcalendaroffice365exchange-serverexchangewebservices

Updating the subject of a M365 recurring calendar event instance


I have an existing application that creates recurring calendar events in M365, using EWS (using direct XML, not the managed API). Sometimes I need to modify one instance, to change the start date/time or end date/time. This works fine. Now I have a requirement to change the subject as well. I have tried using the XML below to add the subject change, but the response from EWS is "invalid request". In the example below, the code separated by blank lines is what I have added. If I remove it, the code to change the start/end works. Can anyone give me some insight on how I can do this?

<ItemChanges>
<t:ItemChange>
<t:ItemId Id="AAMkADNjNjA1MTIxLWNlNm...hlUmz+WdhbqlaGgAJ7054uwAAEA==" ChangeKey="DwAAABYAAACxNOWmTuGVSbP5Z2FuqVoaAAnvIiaK" />
<t:Updates>
<t:SetItemField>
<t:FieldURI FieldURI="calendar:Start" />
<t:CalendarItem>
<t:Start>2023-10-09T20:00:00Z</t:Start>
</t:CalendarItem>
</t:SetItemField>
<t:SetItemField>
<t:FieldURI FieldURI="calendar:End" />
<t:CalendarItem>
<t:End>2023-10-09T21:00:00Z</t:End>
</t:CalendarItem>
</t:SetItemField>

<t:SetItemField>
<t:FieldURI FieldURI="calendar:Subject" />
<t:CalendarItem>
<t:Subject>New subject here</t:Subject>
</t:CalendarItem>
</t:SetItemField>

</t:Updates>
</t:ItemChange>
</ItemChanges>

Solution

  • It needs to be item:subject. Don't forget to include SendMeetingInvitationsOrCancellations attribute:

      <UpdateItem MessageDisposition="SaveOnly" SendMeetingInvitationsOrCancellations="SendToNone" ConflictResolution="AutoResolve" 
                    xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">
          <ItemChanges>
            <t:ItemChange>
              <t:ItemId Id="AAMkAGU2ZW..."
                        ChangeKey="DwAAAB..."/>
              <t:Updates>
                <t:SetItemField>
                  <t:FieldURI FieldURI="item:Subject"/>
                  <t:Message>
                    <t:Subject>Modified Subject</t:Subject>
                  </t:Message>
                </t:SetItemField>
              </t:Updates>
            </t:ItemChange>
          </ItemChanges>
        </UpdateItem>