cancel
Showing results for 
Search instead for 
Did you mean: 

Error with State_Code in API

SOLVED
Occasional Participant

Error with State_Code in API

We are using your API to sync contacts.  We are using the C# Wrapper and we get the below error when adding contacts.

 

json.field.address.state_code.and.state.mismatch:#/addresses/0/state_code: This attribute value does not match the specified state attribute MA.

 

This is happening with multiple states, not just MA. It seems to have started in our system about a month ago. 

 

It looks like when we build the message we fill the State Name and State Code to the "State Code" value which in this case would be MA.  Looking through the API, it looks like this should work and set the State Name by matching the state code in your API.  Do we need to leave the State Name blank?

5 REPLIES
Moderator

Re: Error with State_Code in API

Hello @ColtonH802,

 

Thank you for reaching out to Constant Contact's API Support.

 

When using those fields you need to make sure you are using both the state and the state code. Here is an example of what it should look like in a JSON format.

 

"state_code": "MA",
"state": "Massachusetts"

Regards,
Jimmy D.
Tier II API Support Engineer
Occasional Participant

Re: Error with State_Code in API

Ok.  Would the error we are receiving be from setting the Sate to MA? I thought the API set the State if the correct State_Code was passed in?

 

"state_code": "MA",
"state": "MA"

 

Highlighted
Moderator

Re: Error with State_Code in API

Hi @ColtonH802,

 

It is the other way around. The state is the full state name and it will set the state code.


Regards,
Jimmy D.
Tier II API Support Engineer
Occasional Participant

Re: Error with State_Code in API

It worked to send null for the state_code and the proper state value.  I would like to point out that the API Documentation is incorrect for how the API is behaving. Maybe I am misreading it, but it looks to me like if I submit the proper state_code it should override the state property.

 

state

string (50)

This field accepts any state or province name. However, if a valid 2 letter US state or Canadian province is entered in the state_code field, the system resolves the code to a state or province and overwrites any name manually entered in this field.

state_code

string (2)

Standard 2 letter abbreviation for contact's state or Canadian province; if state_code is entered, the system overwrites the state property with the resolved US state or Canadien province name.

Moderator

Re: Error with State_Code in API

Hi @ColtonH802,

 

I would read this the same way you are reading it. I'll see if we can get this reworded. I'll check if it has always been this way or if we changed it. Thanks for pointing this out.


Regards,
Jimmy D.
Tier II API Support Engineer
Still need help?
You can post a new message in the Community or find us on Twitter Mon-Fri 8am - 8pm ET. We've got real people waiting to help you out. Click below to start a conversation!