The requested URL returned error: 400

NathanJ8
Frequent Participant

The requested URL returned error: 400

Now, When I am trying to create an account by using the partner's name, then the requested API URL shows the error as The requested URL returned error: 400

 

Please suggest me, what to do? How can I resolve this issue?

12 REPLIES 12
bsoder
Employee

Hello,

 

A 400 error usually means that the XML you are sending in your post is malformed.  Could you post the XML here on the forum that you are trying to send to the API server?  I can definitely take a look and see if I see a problem!

 

Regards,

Benjamin Soder
NOC Analyst
Constant Contact
IrynaL
Occasional Participant

Hi,

 

I'm experiencing the same error.

 

Here's my XML:

 

<entry xmlns="http://www.w3.org/2005/Atom">
 <title></title>
 <updated>2011-06-29T19:14:57+01:00</updated>
 <author><name>ItalyTile Website</name></author>
 <id>urn:uuid:E8553C09F4xcvxCCC53F481214230867087</id>
 <summary type="text">Contact</summary>
 <content type="application/vnd.ctct+xml">
  <Contact xmlns="http://ws.constantcontact.com/ns/1.0/">
   <EmailAddress>test@test.com</EmailAddress>
   <FirstName>test</FirstName>
   <LastName></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>CT</StateName>
   <CountryCode>USA</CountryCode>
   <PostalCode></PostalCode>
   <SubPostalCode></SubPostalCode>
   <Note></Note>
   <EmailType>HTML</EmailType>
   <ContactLists>
    <ContactList id="http://api.constantcontact.com/ws/customers/ITALTRADE/lists/1"/>
   </ContactLists>
  </Contact>
 </content>
</entry>

 

Let me know what you think.

Thanks!

 

 

/////////////////// UPDATE ///////////////////////

 

The 400 errors occurs upon calling the addSubscriber method of ConstantContact class. Hope that's helpful.

Please respond promptly!

Hello,

 

I believe the reason you are getting a 400 error is due to the Country Code.  The country code must be US for the United States. Here is a valid list of country codes that can be used.

 

If you have any questions please let me know.

 

Sincerely,

Benjamin Soder
NOC Analyst
Constant Contact
IrynaL
Occasional Participant

Yes, that seem to have fixed it!

 

Thanks!

BilalJ2
Occasional Participant

I'm sorry to bother you with the same issue but  I cant find a solution. I keep getting "The requested URL returned error: 400".

 

Heres the xml data:

 

<entry xmlns="http://www.w3.org/2005/Atom">
<title type="text"></title><updated>2011-12-01 01:28:03</updated>
<author><name>Amanady Products</name></author><id>urn:uuid:565e2c979b514e38924f2127b81fc0db</id>
<summary type="text">Contact</summary>
<content type="application/vnd.ctct+xml">
<Contact xmlns="http://ws.constantcontact.com/ns/1.0/">
<EmailAddress>xxx@yyy.com</EmailAddress>
<FirstName>xxxx</FirstName>
<LastName>yyyy</LastName>
<CompanyName>xw</CompanyName>
<WorkPhone>408</WorkPhone>
<Addr1>2147 Street</Addr1>
<City>Milpitas</City>
<StateCode>CA</StateCode>
<CountryCode>US</CountryCode>
<PostalCode>95035</PostalCode>
<OptInSource>ACTION_BY_CONTACT</OptInSource>
<ContactLists>
<ContactList id="http://api.constantcontact.com/ws/customers/USERNAME/lists/1"></ContactList></ContactLists>
</Contact></content></entry>

XML is correct, what URI are you making the request to and what type of request are you making (PUT, POST, DELETE)?

Dave Berard
Senior Product Manager, Constant Contact

Also, edited your post to hide customer information.

Dave Berard
Senior Product Manager, Constant Contact
BilalJ2
Occasional Participant

the uri is https://api.constantcontact.com/ws/customers/USERNAME  and using POST. Not sure if  the username: Amanady is authorized, connected or has issues.

So you would correctly be recieving an error making a POST request to that URI.  The URI for creating a new contact is the following format:

 

https://api.constantcontact.com/ws/customers/{username}/contacts

 

Documentation on this is found here: http://community.constantcontact.com/t5/Documentation/Creating-a-Contact/ba-p/25059

Dave Berard
Senior Product Manager, Constant Contact
BilalJ2
Occasional Participant

Sorry Dave,

 

I did use the correct URI: https://api.constantcontact.com/ws/customers/{username}/contacts

 

I tried adding a new email address and got this response:

 

curl response:

 

?xml version="1.0" encoding="UTF-8"?
<feed xmlns="http://www.w3.org/2005/Atom">
  <id>http://api.constantcontact.com/ws/customers/Amanady/contacts</id>
  <title type="text">Contacts for Customer: Amanady</title>
  <link href="contacts"></link>
  <link href="contacts" rel="self"></link>
  <author>
    <name>USERNAME</name>
  </author>
  <updated>2011-12-01T18:03:34.514Z</updated>
  <link href="/ws/customers/USERNAME/contacts" rel="first"></link>
</feed>

 

But does not appear on the Active list at constant contact.

 

and the error response:

 

The requested URL returned error: 400

 

[*Note from a CTCT Community Admin: I removed the beginning and ending brackets from the "?xml version="1.0" encoding="UTF-8"?" line in your post above because that line breaks the "Developer Support" tab in our CTCT "Labs JMML Q&A" Facebook app (apparently, the app is trying to render that line as is, which wouldn't be acceptable in the middle of a page).]

Can you post or send us your code that you used for the curl request?  You should not receive an empty Contacts Collection feed when receiving a 400 error, it should be an error message indicating what was wrong with the request.  Since your XML was correct and worked in my account (using a different email address), the only explanation remaining is it's a code/configuration error.  If you post your code here, please obvuscate any personal information such as username/password or email the cdoe to us at webservices@constantcontact.com.

Dave Berard
Senior Product Manager, Constant Contact
DaveBerard
Moderator
Developer Portal

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

Visit Page