Exchange Server TechCenter >
Exchange Server Forums
>
Development
>
EWS Managed API: Problems updating Outlook Contact, Key Not Found, only one property to modify errors
EWS Managed API: Problems updating Outlook Contact, Key Not Found, only one property to modify errors
- Hi,
I'm having strange problems when trying to update a user's contact. I'm using this code:
Now sometimes I get a Key Not Found Exception for contact.PhysicalAddresses[PhysicalAddressKey.Business].City = "city";ExtendedPropertyDefinition[] userFields = new ExtendedPropertyDefinition[] { title }; PropertySet extendedPropertySet = new PropertySet(BasePropertySet.FirstClassProperties, userFields); Contact contact = Contact.Bind(tempService,new ItemId(ewsID),extendedPropertySet); contact.ExtendedProperties.Where(p => p.PropertyDefinition.Tag == 14917).First().Value = newtitle; contact.GivenName = newGivenName; contact.Surname = Surname ; contact.JobTitle = jobtitle; contact.BusinessHomePage = homepage; /*contact.EmailAddresses[EmailAddressKey.EmailAddress1] = "email@email.com"; contact.PhoneNumbers[PhoneNumberKey.MobilePhone] = "1212"; contact.PhoneNumbers[PhoneNumberKey.BusinessFax] = "2323"; contact.PhoneNumbers[PhoneNumberKey.BusinessPhone] = "22323"; contact.PhysicalAddresses[PhysicalAddressKey.Business].City = "city"; contact.PhysicalAddresses[PhysicalAddressKey.Business].CountryOrRegion = "country"; contact.PhysicalAddresses[PhysicalAddressKey.Business].PostalCode = "94550"; contact.PhysicalAddresses[PhysicalAddressKey.Business].Street = "street";*/ contact.Update(ConflictResolutionMode.AlwaysOverwrite);
Then at other times it's stepping over those properties just fine but when calling the update method I receive the error: An object within a change description must contain one and only one property to modify. When I comment those sections out (see code) it updates just fine.
I really don't know what to do about this...- Edited byMalkier Thursday, August 20, 2009 10:50 AMdescription updated
All Replies
- OK, now I found out that it can cause trouble with some properties when the target string value is empty:
contact.EmailAddresses[EmailAddressKey.EmailAddress1] = "";This gives me the "An object within a change description must contain one and only one property to modify" error message.
- Seems to be a problem when setting empty values. I get an error when I do this: testContact.SetExtendedProperty(email1, "");
How can I "empty" the field of a contact? - This bug should be fixed in the Release Candidate we published yesterday. Please upgrade to the RC version of the API and try again.
David Claux | Program Manager - Exchange Web Services - Ok will try this,
can I also empty a field of a user contact now without triggering an exception? - Yes, that should be fixed, too.
David Claux | Program Manager - Exchange Web Services - Hi,
I still get a ServiceResponseException (An object within a change description must contain one and only one property to modify.) with the RC version of the API when I try to do something like this:
Am I doing something wrong?Contact testContact = Contact.Bind(service, new ItemId(Id)); testContact.PhysicalAddresses[PhysicalAddressKey.Business].City = string.Empty; testContact.Update(ConflictResolutionMode.AlwaysOverwrite);
Hi,
I've got the same problem!!
I still get a ServiceResponseException (An object within a change description must contain one and only one property to modify.) with the RC version of the API when I try to do something like this:
Am I doing something wrong?Contact testContact = Contact.Bind(service, new ItemId(Id));
testContact.PhysicalAddresses[PhysicalAddressKey.Business].City = string .Empty;
testContact.Update(ConflictResolutionMode.AlwaysOverwrite);
How can we clear an item from the EmailAddressDictionary? This dictionary itself doesn't have a method called remove() what I expected to have...
Hopefully there is a solution for this problem.- I also have this problem. When I try to assign the EmailAddress1 an empty string (specifically "" because that is what my program reads in when an email address field is empty in SharePoint), I receive a ServiceResponseException with the message of "An object within a change description must contain one and only one property to modify."I think the above problem is unrelated to this problem I am having (http://social.technet.microsoft.com/Forums/en-US/exchangesvrdevelopment/thread/73059e51-c3ab-4bca-a3b1-2c58aa401f48) seeing as I only have the above problem when trying to assign an empty string (I have the problem in the thread I linked to when trying to assign any other value).Have any of you two figured out the problem of assigning an empty string to the email address property? Does anybody else know a solution to this? Is it a bug which is still present in the RC version of the API (seeing as that is what I am now using and still getting this error).Thank you in advance.
I also have this problem. When I try to assign the EmailAddress1 an empty string (specifically "" because that is what my program reads in when an email address field is empty in SharePoint), I receive a ServiceResponseException with the message of "An object within a change description must contain one and only one property to modify."
Well... I have a workaround but that one is pretty radical. In my code I have 2 scenario's.
I think the above problem is unrelated to this problem I am having (http://social.technet.microsoft.com/Forums/en-US/exchangesvrdevelopment/thread/73059e51-c3ab-4bca-a3b1-2c58aa401f48 ) seeing as I only have the above problem when trying to assign an empty string (I have the problem in the thread I linked to when trying to assign any other value).Have any of you two figured out the problem of assigning an empty string to the email address property? Does anybody else know a solution to this? Is it a bug which is still present in the RC version of the API (seeing as that is what I am now using and still getting this error).Thank you in advance.
1) Update Existing contact
2) Add new contact.
The logic in both scenarios is the same and differ at one point. In the first case the contact object is a reference to a loaded contact object and the second case just a new instance.
The contact information is being set from a datasource obviously.
If it's scenario 1 I just deleted the existing contact and then follow scenario numer 2 :-) I know this is verrrry dirty but for the time being it works.
So, my solution : Delete and insert new contact. This way you will never have the 'update one and only one blabla' exception.
Good luck!- Still haven't found a solution to this. Maybe one of the MVPs can advise.
- Thank you for the suggestion 321X :) I may have to resort to that if I cannot find a fix for this, but hopefully there will be a way for us to just be able to update the email address property.


