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.

400 adding a new contact

Highlighted
New Member

400 adding a new contact

Here is my xml for adding:


<entry xmlns="http://www.w3.org/2005/Atom">

    <updated>2010-12-27T17:18:12+01:00</updated>

    <author><name>CTCT Samples</name></author>

    <id>2</id>

    <summary type="text">Customer document</summary>

    <content type="application/vnd.ctct+xml">

        <Contact xmlns="http://ws.constantcontact.com/ns/1.0/">Customer document

            <emailaddress>testemail@gmail.com</emailaddress>

            <firstname>Bob</firstname>

            <lastname>Barker</lastname>

            <middlename></middlename>

            <companyname></companyname>

            <jobtitle></jobtitle>

            <optinsource>ACTION_BY_CUSTOMER</optinsource>

            <homephone></homephone>

            <workphone></workphone>

            <addr1></addr1>

            <addr2></addr2>

            <addr3></addr3>

            <city></city>

            <statecode></statecode>

            <statename></statename>

            <countrycode></countrycode>

            <postalcode></postalcode>

            <subpostalcode></subpostalcode>

            <note></note>

            <emailtype></emailtype>

            <ContactLists>

                <ContactList id="http://api.constantcontact.com/ws/customers/user@name.com/lists/1"/>

            </ContactLists>

        </Contact>

    </content>

</entry>


I keep getting a 400 error. I am getting the list id from the API as well so I know that is working. Any ideas?

3 REPLIES 3
Highlighted
Occasional Advisor

RE: Error 400

Hello,


 


After inspecting your XML, I have found multiple issues with your XML that is causing this error.


 


To correct these errors, please change your ID node from <id>2</id> to <id>data:,none</id>. In addition, the contact details fields are case sensitive, meaning <emailaddress> must be changed to <EmailAddress> in order to function correctly.


 


Lastly, when creating a contact, not all fields are required to be sent. Although sending additional empty fields will not cause any errors, they are not required to be included in your XML for successful contact creation.


 


Please use the following XML as a reference for your future contact creations:


<entry xmlns="http://www.w3.org/2005/Atom">

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

      <EmailAddress>testemail@gmail.com</EmailAddress>

      <FirstName>Bob</FirstName>

      <LastName>Barker</LastName>

      <OptInSource>ACTION_BY_CONTACT</OptInSource>

      <ContactLists>

        <ContactList id="http://api.constantcontact.com/ws/customers/user@name.com/lists/1"/>

      </ContactLists>

    </Contact>

  </content>

</entry>

Andrew T

Support Engineer, Constant Contact

Highlighted
New Member

OK, another problem.

Yes I figured those out. I do not know why my xml was not camel case as the php is correct. I ran it again and it was fine. I also have extra fields because I intend on using them but have not filled them in for initial tests.


I figured out how to remove contacts from the list(not moving to the 'Do Not Mail' list). But when I try to add that same contact again it cannot add because they allready exist. Any ideas? Thanks.

Highlighted
Employee

Re: OK, another problem.

Once an email address has been added to Constant Contact, they are never fully removed. If you have removed the contact from all contact lists and wish to add them back to other lists, you must update the contact that already exists. Typically I would recommend this type of flow for this.


 


1. Search for contact by email address


 


2. If the contact exists, obtain their id from the XML returned from the search and use this to retrieve the full contact details


 


3. Update the contact to include the <ContactList> that you wish for the contact to be subscribed to. You can find more information on this process in Adding or Removing a Contact from a List.


 


This will take the contact out of 'removed' status and place them in whatever list(s) you chose.

David J

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