What can I use for ChangeKey in EWS UpdateItem?

I am trying to use Exchange Web Services to update a calendar item. I create an ItemChangeType and then an ItemIdType. I have a unique identifier for ItemIdType.Id, but I have nothing to use for ChangeKey. When I leave this, I get ErrorChangeKeyRequiredForWriteOperations. But when I try to just add something, I get ErrorInvalidChangeKey.

What can I use for this to make it work?

I am also trying to determine which best implementation of BaseItemIdType is used for ItemChangeType.Item. So far I am using ItemIdType, and I assume this is correct, but I could not find any particularly useful documentation on this subject.

+3
source share
4 answers

To be more explicit in the Hauge response: ChangeKey is stored in Exchange and identifies the current state of the item. Any change to this item creates a new ChangeKey.

This allows Exchange to “know” that your update applies to the same state of the item as when viewing the item — it has not changed since it was checked.

Some code is available at: http://msdn.microsoft.com/en-us/library/aa563020.aspx

+7
source

If you have the ItemIdType.Id property, you must also have access to Changekey, this is also the ItemIdType property:

ItemIdType.ChangeKey

Like the Id property, this is a string, so you can capture it when you capture the identifier.

Relations Jesper Hauge

+2
source

, ChangeKey, , :

  private FolderIdType GetFullFolderID(string folderID)
  {
     GetFolderType request = new GetFolderType();
     request.FolderIds = new BaseFolderIdType[1];

     FolderIdType id = new FolderIdType();
     id.Id = folderID;
     request.FolderIds[0] = id;

     request.FolderShape = new FolderResponseShapeType();
     request.FolderShape.BaseShape = DefaultShapeNamesType.IdOnly;

     GetFolderResponseType response = _binding.GetFolder(request);

     FailOnError(response);

     FolderInfoResponseMessageType firmt = (FolderInfoResponseMessageType)response.ResponseMessages.Items[0];
     FolderType ft = (FolderType)firmt.Folders[0];
     id.ChangeKey = ft.FolderId.ChangeKey;

     return id;
  }
+1

I recommend using the Exchange Managed API instead of Exchange Web Services to work with Exchange. It is much easier to use. You can find more details below:

https://msdn.microsoft.com/en-gb/library/dd877012(v=exchg.150).aspx

+1
source

Source: https://habr.com/ru/post/1697685/


All Articles