cancel
Showing results for 
Search instead for 
Did you mean: 

Error when updating a Contact with StateCode

Occasional Participant

Error when updating a Contact with StateCode

I can not update an existing contact when I include the <StateCode> element in the Atom:

Example Atom:

<entry xmlns="http://www.w3.org/2005/Atom">
 <id>http://api.constantcontact.com/ws/customers/USERNAME/contacts/14</id>
 <title type="text">Contact: test2user534@aol.com</title>
 <author><name>USERNAME</name></author>
 <updated>2008-10-23T09:23:39.654Z</updated>
 <content type="application/vnd.ctct+xml">
  <Contact xmlns="http://ws.constantcontact.com/ns/1.0/" id="http://api.constantcontact.com/ws/customers/USERNAME/contacts/14">
   <EmailAddress>test2user534@icepmt.com</EmailAddress>
   <EmailType>HTML</EmailType>
   <FirstName>Testy</FirstName>
   <LastName>User</LastName>
   <StateCode>CA</StateCode>
   <StateName>California</StateName>
   <CountryCode>us</CountryCode>
   <CountryName>United States</CountryName>
   <ContactLists>
    <ContactList id="http://api.constantcontact.com/ws/customers/USERNAME/lists/1" />
    <ContactList id="http://api.constantcontact.com/ws/customers/USERNAME/lists/2" />
   </ContactLists>
  </Contact>
 </content>
</entry>

The data in the StateCode, StateName, CountryCode and CountryName are all values that were returned from a GET request for the Contact. The original values were created from the Constant Contact website, (adding just a State from their pulldown automatically adds the StateCode and Country information).

If I drop the State and Country tags from the Atom, everyting updates OK.

Any Ideas?
8 REPLIES 8
Valued Developer

re: Error when updating with both a State Code and State Name

From the error message I encountered while testing, it appears that you cannot include Both the State Name(California) and The State Code (CA). I believe the same is true of Country Name (United States) and Country Code (us). I also found that that I needed an optinSource tag in the entry.
Thanks,
Tom M
Group Product Manager – Content Editing
Constant Contact
Occasional Participant

Still not working....

I tried removing both the StateCode and the StateName Tags, I also tried using just StateCode and another try as just StateName. If I go to the ConstantContact site and remove the State from the Contact Details the record can be updated OK from the API, (the API does not seem to allow you to update a Contact with a StateCode or StateName even if you do not submit that tag in the Atom). The CountryCode tag seems to work OK, (although I did not try submitting both).

I also tested adding the ContactLists with and without the OptInSource tags. It seems that you do not need the OptInSource if your Lists all have the OptInDefault set to True.

I am not sure if I have any reason to update a Contacts Mailing Address since the E-Mailing option does not need anything other than a valid EMail Address, but if the Contact or Customer somehow adds the Contact Detail State, I will no longer be able to add or update any list information for that Contact given the current state of the API.
Valued Developer

RE: Inability to Set State/Country

I just confirmed this behavior and submitted a defect for it. Note that you can update the contacts as long as you include empty StateCode and CountryCode tags. Ie. include these lines:

<StateCode></StateCode>
<CountryCode></CountryCode>


This will not override the current State and Country settings if they have already been set. It will allow you to update the other fields in the Contact.

Finally, you are correct in that you only require the <OptInSource> tag when one or more of the Contact Lists you are adding the Contact to is not included on the contact Sign-up Form.
Tom M
Group Product Manager – Content Editing
Constant Contact
Participant

Any word on this bug

Any word on this bug yet?

Aaron

StateCode

I'm interested in this bug as well. Any news?
Valued Developer

re: State Code | Country Code Workaround

We have scheduled a fix for the defect. In the meantime, there is a workaround.



To update a Contact that already has a value in the State field, simply make sure that you provide a value in either StateCode OR StateName. Make sure you include an empty tag for the value you do not set. In essence, you are 'clearing' one of these redundant values (say StateCode) and setting the other value (StateName).





To update a Contact that already has a value in the Country field, simply make sure that you provide a value in either CountryCode OR CountryName. Make sure you include an empty tag for the value you do not set. In essence, you are 'clearing' one of these redundant values (say CountryCode) and setting the other value (CountryName).




For example, I was able to use this XML to update a Contact that already had State and Country values set to Quebec, Canada:

...snip

<StateCode>MA</StateCode><StateName></StateName>
<CountryCode>US</CountryCode><CountryName></CountryName>

snip...




thanks,
Tom M
Group Product Manager – Content Editing
Constant Contact
Participant

Thanks, Tom. That seems to

Thanks, Tom. That seems to work. Please let us know when the bug fix is in place.
Occasional Participant

State Code and Country Codes for XML

The set of state codes and country codes which are used in the Contact XML are documented here:

The supported CountryCodes are documented here:
http://constantcontact.custhelp.com/cgi-bin/constantcontact.cfg/php/enduser/std_adp.php?p_faqid=3614.

The supported state codes are here:
http://ui.constantcontact.com/CCSubscriberAddFileFormat.jsp#states.