Reply
Occasional Contributor
danp459
Posts: 7
Registered: ‎04-09-2012

The requested URL returned error: 400

		// If the subscriber already exists then we're updating their list choices 

if( $iContactId = $oConstantContact->subscriberExists($aPostFields['email_address']) ){ $sContactXML = $oConstantContact->createContactXML( $iContactId, $aPostFields ); $bError = !$oConstantContact->editSubscriber( $iContactId, $sContactXML ); }else{ // New Contact $sContactXML = $oConstantContact->createContactXML( null, $aPostFields ); $bError = !$oConstantContact->addSubscriber($sContactXML); }

 The error is occuring at the last line, addSubscriber.  the "The requested URL returned error: 400" is being echo'd into my page, i didnt tell it to echo.  

Mark-C
Posts: 181
Topics: 3
Kudos: 10
Solutions: 14
Registered: ‎07-23-2011

Re: The requested URL returned error: 400

Hello,

 

The 400 error is most commonly caused by some problem with the structure or content of the XML being submitted in your request body.  It may be helpful to dump that $sContactXML variable to your browser, and take a look at it...  You can post it here (remove any unique identifiers for the contact before posting).  You can also PM it to me, if you are more comfortable with that.

 

Cheers,

Mark Coleman
Support Engineer
Occasional Contributor
danp459
Posts: 7
Registered: ‎04-09-2012

Re: The requested URL returned error: 400

<entry xmlns="http://www.w3.org/2005/Atom">
<title>TitleNode</title>
<updated>
2012-04-10T11:07:56+01:00
</updated>
<author>
  <name>CTCT Samples</name>
</author>
<id>urn:uuid:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</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>asdf@asdf.com</EmailAddress>
    <FirstName>First Name*</FirstName>
    <LastName>Last Name</LastName>
    <MiddleName></MiddleName>
    <CompanyName></CompanyName>
    <OptInSource>ACTION_BY_CUSTOMER</OptInSource>
    <HomePhone>Phone Number</HomePhone>
    <WorkPhone></WorkPhone>
    <Addr1></Addr1>
    <Addr2></Addr2>
    <Addr3></Addr3>
    <City>City</City>
    <StateCode></StateCode>
    <StateName>State</StateName>
    <CountryCode></CountryCode>
    <PostalCode></PostalCode>
    <SubPostalCode></SubPostalCode>
    <Note>contact</Note>
    <EmailType>HTML</EmailType>
    <ContactLists>
      <ContactList id="https://api.constantcontact.com/ws/customers/blackmarkethotsauce/lists/"/>
    </ContactLists>
  </Contact>
</content>
</entry>

Occasional Contributor
danp459
Posts: 7
Registered: ‎04-09-2012

Re: The requested URL returned error: 400

ah, the error was i wasnt setting the lists url properly.  This is the second time i've had  error: #someNumber.  It sure would be nice if this api gave some more info back.

Mark-C
Posts: 181
Topics: 3
Kudos: 10
Solutions: 14
Registered: ‎07-23-2011

Re: The requested URL returned error: 400

Hello,

 

I'm glad the cause of the error revealed itself in the XML. With the 400 errors that is usually the case. I'm also going to look at the error handling and how they are reported by the wrapper.  It may take me a little time to do that, but in the meantime, I can direct you to this documentation on the API error codes.

 

Cheers,

Mark Coleman
Support Engineer
Mark-C
Posts: 181
Topics: 3
Kudos: 10
Solutions: 14
Registered: ‎07-23-2011

Re: The requested URL returned error: 400

Based on the name of the function called in the original code you posted, it looks like you are using the CCSFG.  In that package, the file cc_class.php library contains the code that is echoing the error returned by the doServerCall function that starts around line 46 of the unaltered file.  I believe you're looking for the following line:

 

echo  $return['error']; 

 

which occurs on line 89 of the unaltered script.  This can be commented out or revised to write the API call errors to a file.

 

I hope this was helpful. Let me know if you have any other questions.

Mark Coleman
Support Engineer