none
Exchange web service --- problem in updating start/end time of a calendar appointment (ErrorIncorrectUpdatePropertyCount) RRS feed

  • Question

  • Hi, all experts. I just found a problem, when I try to update the calendar start/end time using exchange web service. After excuting, the error code is always ErrorIncorrectUpdatePropertyCount, I had looked up the error information on help menu, it said:

    Each change description in an UpdateItem or UpdateFolder method call must list only one property to update.

    But I really did not add any more updates in the update request,  And I can use similar code to update other fields for calendar except start/end time. any one can point me out why?

    Here is my code below:

     

    ExchangeServiceBinding ecb = new ExchangeServiceBinding();
          ecb.UseDefaultCredentials = true;
          ecb.Url = "https://servername/EWS/Exchange.asmx";
    
          UpdateItemType updateItemRequest = new UpdateItemType();
    
          updateItemRequest.SavedItemFolderId = new TargetFolderIdType();
          updateItemRequest.SavedItemFolderId.Item = new DistinguishedFolderIdType();
          (updateItemRequest.SavedItemFolderId.Item as DistinguishedFolderIdType).Id
            = DistinguishedFolderIdNameType.calendar;
    
          updateItemRequest.MessageDisposition = MessageDispositionType.SaveOnly;
          updateItemRequest.MessageDispositionSpecified = true;
    
          updateItemRequest.SendMeetingInvitationsOrCancellations = CalendarItemUpdateOperationType.SendToNone;
          updateItemRequest.SendMeetingInvitationsOrCancellationsSpecified = true;
    
          //Create a new change
          ItemChangeType change = new ItemChangeType();
    
          //add item ID and change key
          ItemIdType idItem = new ItemIdType();
          idItem.ChangeKey = "DwAAABYAAAAeVB3gQMYXQIU7ofrHTRY2ABPVJqhL";
          idItem.Id = "AAAiAHhpYW5naHVpLmRvbmdAcGluZXJpdmVyY2FwaXRhbC5jb20ARgAAAAAAz2QPPg8fq0aPkLzLPeZv7wcAHlQd4EDGF0CFO6H6x00WNgAT1SNhzAAAtsbqRPou+Ua5g7NFjWwfOQAT1nsIBgAA";
    
          change.Item = idItem;
    
          //Add update
          SetItemFieldType setStartTime = new SetItemFieldType();
    
          //Set change object to calendar start time
          PathToUnindexedFieldType itemField = new PathToUnindexedFieldType();
          itemField.FieldURI = UnindexedFieldURIType.calendarStart;
          setStartTime.Item = itemField;
    
          //Set change value
          CalendarItemType itemValue = new CalendarItemType();
          itemValue.Start = new DateTime(2011, 1, 5, 12, 0, 0).ToUniversalTime();
          setStartTime.Item1 = itemValue;
    
          change.Updates = new ItemChangeDescriptionType[] { setStartTime };
    
          updateItemRequest.ItemChanges = new ItemChangeType[] { change };
    
          UpdateItemResponseType updateResult = null;
          try
          {
            updateResult = ecb.UpdateItem(updateItemRequest);
          }
          catch (Exception ex)
          {
            throw ex;
          }
    
          if (updateResult == null)
          {
            Debug.WriteLine("Update failed: updateResult is null");
            return;
          }
          if (updateResult.ResponseMessages == null)
          {
            Debug.WriteLine("Update failed: updateResult.ResponseMessages is null");
            return;
          }
          ArrayOfResponseMessagesType responseMessages = updateResult.ResponseMessages;
          if (responseMessages.Items == null || responseMessages.Items.Length == 0)
          {
            Debug.WriteLine("Update failed: updateResult.ResponseMessages.Items is null");
            return;
          }
          ResponseMessageType responseMessage = responseMessages.Items[0];
          //if the response indicates an error, the update is failed
          if (responseMessage.ResponseCode != ResponseCodeType.NoError)
          {
            //Here ErrorIncorrectUpdatePropertyCount is always returned
            Debug.WriteLine(string.Format("Update failed: {0}", responseMessage.ResponseCode));
            return;
          }

     

    Monday, January 10, 2011 11:31 AM

Answers

  • Hello Alix Dong,

    It looks like you are missing the field value to update. The Start property is not being serialized. Please add the following after itemValue.Start:

    itemValue.StartSpecified = true; 

    With regards,


    Michael | Microsoft Exchange SDK

    The Exchange Development Forum Guide has useful information for using the Exchange Development Forum.

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    Wednesday, January 12, 2011 10:05 PM
    Moderator

All replies

  • Hello Alix Dong,

    Can you provide the XML for the request and response by using the information found here: http://msdn.microsoft.com/en-us/library/bb204041(EXCHG.140).aspx? It will help us identify the issue.

    Is there a reason why you aren't using the EWS Managed API for application? Download it here.

    With regards,


    Michael | Microsoft Exchange SDK

    The Exchange Development Forum Guide has useful information for using the Exchange Development Forum.

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    Monday, January 10, 2011 11:21 PM
    Moderator
  • Thanks Michael, here is the XML request:

    <?xml version="1.0" encoding="utf-8" ?>

    - <UpdateItemType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" ConflictResolution="NeverOverwrite" MessageDisposition="SaveOnly" SendMeetingInvitationsOrCancellations="SendToNone">
    - <SavedItemFolderId xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">
      <DistinguishedFolderId Id="calendar" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" />
      </SavedItemFolderId>
    - <ItemChanges xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">
    - <ItemChange xmlns="http://schemas.microsoft.com/exchange/services/2006/types">
      <ItemId Id="AAAiAHhpYW5naHVpLmRvbmdAcGluZXJpdmVyY2FwaXRhbC5jb20ARgAAAAAAz2QPPg8fq0aPkLzLPeZv7wcAHlQd4EDGF0CFO6H6x00WNgAT1SNhzAAAtsbqRPou+Ua5g7NFjWwfOQAT1nsIBgAA" ChangeKey="DwAAABYAAAAeVB3gQMYXQIU7ofrHTRY2ABPVJrpE" />
    - <Updates>
    - <SetItemField>
      <FieldURI FieldURI="calendar:Start" />
      <CalendarItem />
      </SetItemField>
      </Updates>
      </ItemChange>
      </ItemChanges>
      </UpdateItemType>
    And Here is the response:
    <?xml version="1.0" encoding="utf-8" ?>
    - <UpdateItemResponseType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    - <ResponseMessages xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">
    - <UpdateItemResponseMessage ResponseClass="Error">
      <MessageText>An object within a change description must contain one and only one property to modify.</MessageText>
      <ResponseCode>ErrorIncorrectUpdatePropertyCount</ResponseCode>
      <DescriptiveLinkKey>0</DescriptiveLinkKey>
      <Items />
      </UpdateItemResponseMessage>
      </ResponseMessages>
      </UpdateItemResponseType>
    Tuesday, January 11, 2011 5:19 AM
  • Hello Alix Dong,

    It looks like you are missing the field value to update. The Start property is not being serialized. Please add the following after itemValue.Start:

    itemValue.StartSpecified = true; 

    With regards,


    Michael | Microsoft Exchange SDK

    The Exchange Development Forum Guide has useful information for using the Exchange Development Forum.

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    Wednesday, January 12, 2011 10:05 PM
    Moderator