Reply
New Member
Acuity
Posts: 2
Registered: ‎01-28-2011

The remote server returned an error: (400) Bad Request

Hi All,


I am trying to add new contact into Contact List through using c# sample code. I am able to get Contact list and when i try to add new contact into existing optin list then it throw error "The remote server returned an error: (400) Bad Request"


Here is the request which i am sending it


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

  <title type="text" />

  <updated>2008-07-23T14:21:06.407Z</updated>

  <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>sds@yahoo.com</EmailAddress>

  <FirstName />

  <MiddleName />

  <LastName />

  <HomePhone />

  <Addr1 />

  <Addr2 />

  <Addr3 />

  <City />

  <StateCode />

  <StateName />

  <PostalCode />

  <SubPostalCode />

  <CountryCode />

  <CompanyName />

  <JobTitle />

  <WorkPhone />

  <EmailType>HTML</EmailType>

  <OptInSource>ACTION_BY_CONTACT</OptInSource>

  <Note />

  <CustomField1 />

  <CustomField2 />

  <CustomField3 />

  <CustomField4 />

  <CustomField5 />

  <CustomField6 />

  <CustomField7 />

  <CustomField8 />

  <CustomField9 />

  <CustomField10 />

  <CustomField11 />

  <CustomField12 />

  <CustomField13 />

  <CustomField14 />

  <CustomField15 />

  <ContactLists>

  <ContactList id="http://api.constantcontact.com/ws/customers/AcuityTest/lists/Acuity Contact List" />

  </ContactLists>

  </Contact>

  </content>

  </entry>

 


Please let me know what is the issue?


 


Thanks


Acuity Team


 

CTCT Employee
David_J
Posts: 512
Registered: ‎06-04-2009

Re: The remote server returned an error: (400) Bad Request

Your XML looks like it is meant to create a single contact (sds@yahoo.com) rather than a Contact List itself. In order for the XML above to create a contact, you would just need to modify your <ContactList> id to use the list id rather than the name of the list.


For example:


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


 


instead of:


<ContactList id="http://api.constantcontact.com/ws/customers/AcuityTest/lists/Acuity Contact List" />


 


You can find the id of any of your lists from the Lists collection.


 


I hope this helps, please let me know if you have any questions or concerns regarding this. Thank you.

David J

New Member
Acuity
Posts: 2
Registered: ‎01-28-2011

Connection Closed Error.

Thanks for reply, Today i am trying to run my application again but i am getting error "The underlying connection was closed: The connection was closed unexpectedly."


Same code was working yestarday, Please let me know what is the issue


My Login Account Id = AcuityTest


Thanks


 

CTCT Employee
bsoder
Posts: 440
Registered: ‎06-05-2009

API not working

Hello,



Yesterday our API servers were temporarily down for a period between 12:50pm and 6:00pm. During that time you would have received errors such as that.



It should be working fine now, if you are still running into issues after this, please let us know here.



Regards,

Benjamin Soder
NOC Analyst
Constant Contact
Occasional Participant
hienh8
Posts: 4
Registered: ‎11-16-2011

Re: The remote server returned an error: (400) Bad Request

Hi All,

I'm getting 400 Bad request error when I using POST method to add new contact. Here is my XML:

<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>hien@yahoo.com</EmailAddress>
<FirstName>hien</FirstName>
<MiddleName></MiddleName>
<LastName>hien</LastName>
<HomePhone></HomePhone>
<Addr1>123</Addr1>
<Addr2></Addr2>
<Addr3></Addr3>
<City>tp</City>
<StateCode></StateCode>
<StateName></StateName>
<PostalCode></PostalCode>
<SubPostalCode></SubPostalCode>
<CountryCode>vn</CountryCode>
<CompanyName></CompanyName>
<JobTitle></JobTitle>
<WorkPhone></WorkPhone>
<EmailType>HTML</EmailType>
<OptInSource>ACTION_BY_CUSTOMER</OptInSource>
<Note></Note>
<CustomField1>1</CustomField1>
<CustomField2>2</CustomField2>
<CustomField3>3</CustomField3>
<CustomField4>4</CustomField4>
<CustomField5>5</CustomField5>
<CustomField6>6</CustomField6>
<CustomField7></CustomField7>
<CustomField8></CustomField8>
<CustomField9></CustomField9>
<CustomField10></CustomField10>
<CustomField11></CustomField11>
<CustomField12></CustomField12>
<CustomField13></CustomField13>
<CustomField14></CustomField14>
<CustomField15></CustomField15>
<ContactLists><ContactList id="http://api.constantcontact.com/ws/customers/hienbt/lists/4"/>
</ContactLists></Contact>
</content></entry>

What am I missing?
Thanks!

Nick_G
Posts: 162
Kudos: 12
Solutions: 9
Registered: ‎04-20-2011

Re: The remote server returned an error: (400) Bad Request

Hello,

 

What is the URL that you are POSTing the information to? Also, is there any body returned with your 400 error?

 

I would also suggest that you take a look at running RESTclient. You can run the same XML through this program, then if you receive the same error, you can save your request as a .RCQ file and email it to webservices@constantcontact.com for us to take a look at.

 

Let me know if you have any questions. Thanks!

Nick Galbraith
Support Engineer
Occasional Participant
hienh8
Posts: 4
Registered: ‎11-16-2011

Re: The remote server returned an error: (400) Bad Request

[ Edited ]

Hi Nick_G


 Thanks for help from you.

I using https://api.constantcontact.com/ws/customers/hienbt/contacts to POST . Cause my data is wrong enter, I fixed it .

Occasional Participant
hienh8
Posts: 4
Registered: ‎11-16-2011

Re: The remote server returned an error: (400) Bad Request

Hi Nick_G


I'm trying to add new contact into Contact List A, but this contact had existed in Contact List B through using c# sample code. So, it appear error 409
How do to solve this issue?

 

Thanks!

DaveBerard
Posts: 1,648
Topics: 7
Kudos: 62
Solutions: 61
Registered: ‎06-19-2008

Re: The remote server returned an error: (400) Bad Request

Once a Contact is created, all subsequent changes must be done using update requests.  In the C# wrapper, this should be done using updateContact() method in the Utility.  You would need to do a getContact request by either the ID or the Email Address and then update the Contact to change their information. 

Dave Berard
Senior Product Manager, Constant Contact