The Community is hosting an End of Summer sweepstakes! Participants must complete tasks to earn tickets that will enter them with a chance to win a free year of Constant Contact and other great prizes!*
*No Purchase Necessary. For Official Rules, visit here. Constant Contact’s End of Summer 2020 Sweepstakes ends on October, 20, 2020 at 11:50 PM EST.

Error 400 adding new contact via ctctwspylib

SOLVED
Go to solution
Highlighted
Occasional Contributor

Error 400 adding new contact via ctctwspylib

There's no shortage of the 400 errors others have had that I see on the forum, but I'm using the sanctioned python Constant Contact API ( http://www.ctctlabs.com/index.php/blog/detail/ctct_web_services_python_client_library/ ) and still having problems. Below is the (mostly) verbatim XML I'm using to create a new user:

 

    <title type="text"></title>
    <updated>2008-07-23T14:21:06.407Z</updated>
    <author></author>
    <id>data:,none</id>
    <summary type="text">Contact</summary>
    <content type="application/vnd.ctct+xml">
        <Contact xmlns="http://ws.constantcontact.com/ns/1.0/">
            <Status></Status>
            <EmailAddress>_redacted_</EmailAddress>
            <EmailType></EmailType>
            <FirstName>Test</FirstName>
            <MiddleName></MiddleName>
            <LastName>Support</LastName>
            <JobTitle></JobTitle>
            <CompanyName>Demo Account</CompanyName>
            <HomePhone></HomePhone>
            <WorkPhone></WorkPhone>
            <Addr1>4 Ivory Way</Addr1>
            <Addr2></Addr2>
            <Addr3></Addr3>
            <City>Holyoke</City>
            <StateCode></StateCode>
            <StateName>MA</StateName>
            <CountryCode>us</CountryCode>
            <CountryName></CountryName>
            <PostalCode>01040</PostalCode>
            <SubPostalCode></SubPostalCode>
            <Note></Note>
            <CustomField1></CustomField1>
            <CustomField2></CustomField2>
            <CustomField3></CustomField3>
            <CustomField4></CustomField4>
            <CustomField5></CustomField5>
            <CustomField6></CustomField6>
            <CustomField7></CustomField7>
            <CustomField8></CustomField8>
            <CustomField9></CustomField9>
            <CustomField10></CustomField10>
            <CustomField11></CustomField11>
            <CustomField12></CustomField12>
            <CustomField13></CustomField13>
            <CustomField14></CustomField14>
            <CustomField15></CustomField15>
            <OptInSource>ACTION_BY_CUSTOMER</OptInSource>
            
            <ContactLists>
                <ContactList id="http://api.constantcontact.com/ws/customers/_redacted_/lists/5" />
            </ContactLists>
        </Contact>
    </content>
</entry>
Any ideas? Given how common this problem seems to be, perhaps the response could be a little more specific in the future. Thanks in advanced for any pointers.
Ken Kimmel
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Trusted Contributor

Re: Error 400 adding new contact via ctctwspylib

Hi Ken, 

 

I managed to squeak out some testing this evening and found that that this may be related to some updates we are making to our API. This appears to be the result of a progressive update of our API. The udpated servers will not accept this XML, because they run a validation of StateCode and StateName to ensure they match the given CountryCode or CountryName (if provided). In your XML, you actually have the StateCode "MA" in the StateName element.  Adding it instead as a StateCode worked every time in my testing.

 

Moving forward, our API will be more rigorously validating these for correspondence.

Mark Coleman
Support Engineer

View solution in original post

4 REPLIES 4
Highlighted
Trusted Contributor

Re: Error 400 adding new contact via ctctwspylib

Hi Ken,

 

The python library was put out as open source and unsupported by Constant Contact Labs, but regardless I'm happy to help try and diagnose the issues using RESTClient (which you can also do)... Unfortunately, I've identified an inconsistency in repsonses to the same request that indicates we may be having an issue with our API Services at this time. I hope to have more to report on this by later this evening, but at this hour, I may not have moreuntil the morning.

Mark Coleman
Support Engineer
Highlighted
Trusted Contributor

Re: Error 400 adding new contact via ctctwspylib

Hi Ken, 

 

I managed to squeak out some testing this evening and found that that this may be related to some updates we are making to our API. This appears to be the result of a progressive update of our API. The udpated servers will not accept this XML, because they run a validation of StateCode and StateName to ensure they match the given CountryCode or CountryName (if provided). In your XML, you actually have the StateCode "MA" in the StateName element.  Adding it instead as a StateCode worked every time in my testing.

 

Moving forward, our API will be more rigorously validating these for correspondence.

Mark Coleman
Support Engineer

View solution in original post

Highlighted
Occasional Contributor

Re: Error 400 adding new contact via ctctwspylib

Hi Mark,

 

You nailed it! Changing the state name to state code worked like a charm. Unfortunately, we are adding contacts dynamically using user-entered values which we're not validating for the sake of convenience. Having rigid state name/code requirements might be an issue if users aren't careful entering data, or if they type of the state name instead of the code. I wonder if other users are experiencing similar issues.

 

This certainly helps, though, and should work for most of our new contacts. I appreciate the quick and helpful response.

 

Ken Kimmel
Highlighted
Moderator

Re: Error 400 adding new contact via ctctwspylib

Thanks Ken, we're looking at this now.  Traditionally, we don't validate StateName.  Going to work with our engineering teams to see if this is intentional and a new validation scheme going forward or if this is a bug and we need to fix it.  Will post an update once I have that info.

Dave Berard
Senior Product Manager, Constant Contact
Developer Portal

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

Visit Page

Constant Contact 2020 End of Summer Community Sweepstakes!

The Constant Contact User Community is hosting a sweepstakes. The more you participate, the more chances you have to win! Read on to learn more...

Read More
Featured