Bulk Import does not allow set 'state' field for non US/CA countries

Highlighted
Visitor

Bulk Import does not allow set 'state' field for non US/CA countries

Hi,

I'm using C# library wrapper but I believe there is a problem on API side because it's a weird validation about addresses

I have the following error trying to bulk import using the API: "json.field.invalid:#/import_data/0/addresses/0/state: Property was found but is not permitted at this location."

 

 

According to error message there is a problem with state field of address object, when I comment the line the assignment of the field 'StateName' of object CTCT.Components.Contacts.Address the contact import works fine, but any value on that field cause the API error:

 

 

Sample code:

 

List<AddContactsImportData> bulkContacts = new List<AddContactsImportData>();

 

AddContactsImportData singleContact = new AddContactsImportData();

 

// set contact fields 

//...

//...

 

CTCT.Components.Contacts.Address ccAddress = new CTCT.Components.Contacts.Address();

ccAddress.AddressType = CTCT.Components.Contacts.AddressType.Personal;

ccAddress.Line1 = "Test 1";
ccAddress.Line2 = "Test 2";
ccAddress.City = "City 1";
ccAddress.StateName = "State 1";  // this cause the error, does not matter the value
ccAddress.PostalCode = "12345";
ccAddress.CountryCode = "BO";

 

 

singleContactAddresses.Add(ccAddress);

 

List<string> lists = new List<string>() { "123456" };  // real id removed

 

var addContacts = new AddContacts(bulkContacts, lists, null);
var activity = activityService.CreateAddContactsActivity(addContacts);

 

 

Detail:


CTCT.Exceptions.CtctException: json.field.invalid:#/import_data/0/addresses/0/state: Property was found but is not permitted at this location.
---> System.Exception: json.field.invalid:#/import_data/0/addresses/0/state: Property was found but is not permitted at this location.

at CTCT.Util.RawApiResponse.Get[T]() in c:\Projects\Dev\ConstantContactLib.Net\CTCTWrapper\Util\RawApiResponse.cs:line 86
at CTCT.Services.ActivityService.CreateAddContactsActivity(AddContacts addContacts) in c:\Projects\Dev\ConstantContactLib.Net\CTCTWrapper\Services\ActivityService.cs:line 88


I believe setting the custom state name (for non US/CA countries) it's basic feature, I cannot use the stateCode field because the address it's not at US/CA.



ref:

http://developer.constantcontact.com/docs/contacts-api/contacts-resource.html

 

"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."

 

 

 

Any help?

 

 

1 REPLY 1
Highlighted
Honored Contributor

Re: Bulk Import does not allow set 'state' field for non US/CA countries

Hello,

 

Thank you for providing so much detail! After looking into this and a quick bit of testing to confirm, there is a special exception to how states are handled for Bulk Imports. When importing in bulk, all data relating to the State field should be stored in the state_code field.  You can find a note about this in the Bulk Import Documentation:

NOTE: For bulk imports only, the state_code field is an 50 character free-form text input field. 

If you continue to have any problems after making this switch, please let me know!

 

Sincerely,

 

 

Elijah G.
API Support Engineer
Developer Portal

View API documentation, code samples, get your API key.

Visit Page

Constant Contact Would Like To Hear From You!

We want to hear from customers like you about your favorite features and how they have helped your business or organization. Tell us by answering a few questions in...

Read More
Featured