cancel
Showing results for 
Search instead for 
Did you mean: 

Issue with State field in API

Regular Visitor

Issue with State field in API

We are using the CTCT .net SDK and am having some issues saving the contact lists when trying to pass the state value. I am providing a json request the wrapper emits that fails and also one that works using the state_code field instead. The error comming back from the first request is ...

[
{
"error_key": "json.field.invalid",
"error_message": "#/import_data/0/addresses/0/state: Property was found but is not permitted at this location."
}
]
-----------------------------------------
Bad Request

-----------------------------------------

{
"column_names": [
"EMAIL",
"CITY",
"Zip/Postal Code",
"STATE",
"ADDRESS LINE 1",
"FIRST NAME",
"LAST NAME"
],
"import_data": [
{
"addresses": [
{
"address_type": "BUSINESS",
"city": "Austin",
"country_code": "",
"line1": "1300 South MoPac Expressway, 3rd Floor",
"line2": "",
"postal_code": "78746",
"state": "TXsadasd"
}
],
"custom_fields": [],
"email_addresses": [
"jairey.satuit@gmail.com"
],
"first_name": "Jonathan",
"last_name": "Airey"
}
],
"lists": [
"1476330905"
]
}

 

-------------------------------------

Good Request

-------------------------------------

{
"column_names": [
"EMAIL",
"CITY",
"Zip/Postal Code",
"STATE",
"ADDRESS LINE 1",
"FIRST NAME",
"LAST NAME"
],
"import_data": [
{
"addresses": [
{
"address_type": "BUSINESS",
"city": "Austin",
"country_code": "",
"line1": "1300 South MoPac Expressway, 3rd Floor",
"line2": "",
"postal_code": "78746",
"state_code": "TXsadasd"
}
],
"custom_fields": [],
"email_addresses": [
"jairey.satuit@gmail.com"
],
"first_name": "Jonathan",
"last_name": "Airey"
}
],
"lists": [
"1476330905"
]
}

1 REPLY 1
Highlighted
Moderator

Re: Issue with State field in API

Hello @RamonR560,

 

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

 

You would use "state_code" if you use the "country_code" and set it to US, or CA.

 

If you do not use the "country_code" or set it to null then you would use "state".

 

If you are updating a contact that previously was set to US, or CA and your entry is "country_code": "", (like the example you provided) then it would be taking the previous data that was in the Constant Contact account. Since the version with "state_code" is working that leads me to believe this contact was previously set with an address in the US, or CA.

 

I would do a GET on this contact and see what their previous address information shows.

 

 

 


Regards,
Jimmy D.
Tier II API Support Engineer