Error 400 Bad request while updating a contact

Highlighted
New Member

Error 400 Bad request while updating a contact

Hi,

We have an old development based on the .NET wrapper library of Constant Contact's V1 API that has been succesfully working for several months. But, since the last week, we are getting an error when attempting to update a contact.

The code we're using with your wrapper is as follows:

Contact xContactTemp = Utility.GetContactDetailsById(AuthenticationData, xContactList[0].Id);

if (xContactTemp.ContactLists.Count > 0 )
{
    xContactTemp.ContactLists.Clear();
    xContactTemp.Status = ContactStatus.Removed;
    Utility.UpdateContactFullForm(AuthenticationData, xContactTemp);
}

 

The UpdateContactFullForm function throws an exception error 400 Bad request. The XML that is generated from the UpdateContactFullForm function is as follows:

<entry xmlns="http://www.w3.org/2005/Atom">
    <title type="text"></title>
    <updated>2008-07-23T14:21:06.407Z</updated>
    <author><name>Constant Contact</name></author>
    <id>http://api.constantcontact.com/ws/customers/*username*/contacts/*idcontact*</id>
    <summary type="text">Contact</summary>
    <content type="application/vnd.ctct+xml">
        <Contact xmlns="http://ws.constantcontact.com/ns/1.0/" id="http://api.constantcontact.com/ws/customers/*username*/contacts/*idcontact*">
            <EmailAddress>mail@mail.com</EmailAddress>
            <FirstName>Name</FirstName>
            <LastName></LastName><MiddleName></MiddleName>
            <OptInSource>ACTION_BY_CONTACT</OptInSource>
            <HomePhone></HomePhone><Addr1></Addr1><Addr2></Addr2><Addr3></Addr3>
            <City>Afghanistan</City>
            <StateCode></StateCode><StateName></StateName><CountryCode></CountryCode><CountryName></CountryName><PostalCode></PostalCode><SubPostalCode></SubPostalCode>
            <EmailType>HTML</EmailType>
            <WorkPhone></WorkPhone><JobTitle></JobTitle><CompanyName></CompanyName><Note></Note><CustomField1></CustomField1>
            <CustomField2>Selected option</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>
            <ContactLists></ContactLists>
        </Contact>
    </content>
</entry>

 


 I've validated the XML structure and seems to be correct but I'm still getting the 400 Bad request response.
 
 Has anything changed recently?  Any idea about it?
 
 Any assistance would be greatly appreciated.
 
 Thanks in advance.
 
 Teo

3 REPLIES 3
Highlighted
Moderator

Re: Error 400 Bad request while updating a contact

Looking at your XML, there are no errors (which you assumed as well since this previously worked).  A fix we recently did due to Contacts being incorrectly added to the Do-Not-Mail list (Unsubscribed) inadvertantly caused this code to break.  We're looking at this now and will update soon.

 

As a side note, if you change the OptInSource to ACTION_BY_CUSTOMER instead of ACTION_BY_CONTACT, your code will go back to working.  This will then correctly move the Contact to a Removed state.

Dave Berard
Senior Product Manager, Constant Contact
Highlighted
Occasional Participant

Re: Error 400 Bad request while updating a contact

Has this been fixed yet? I'm trying to use classic ASP (VB) code to automatically add new contact info into a list, and I'm getting:

 

0 :Bad Request. Check Submitted Data

 

(Maybe my problem is unrelated.)

 

 

Highlighted
CTCT Employee

Re: Error 400 Bad request while updating a contact

Hi,

 

I think you should modify your XML to either add lists to the ContactLists node, as pictured below, or change the OptInSource node to be "ACTION_BY_CUSTOMER" instead of action by contact as it currently is.  Your XML would indicate that the contact themself is adding them to 0 lists, therefore unsubscribing themself.  If that is the case, you don't need this XML at all--you should issue a DELETE request to the contact's URI to unsubscribe them.

 

 <ContactLists>
        <ContactList id="http://api.constantcontact.com/ws/customers/joesflowers/lists/1" />
 </ContactLists>

 

 

Best Regards,

Shannon W.

API Support Specialist

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