We all started somewhere! Share your experience on the Get Advice: Let's Get Started Sweepstakes thread and be entered to win a $100 credit on your Constant Contact account.

HTTP Response Code '403'Received: JBoss Web/2.1.2.GA - Error report


HTTP Response Code '403'Received: JBoss Web/2.1.2.GA - Error report

$ch = curl_init();

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

<title type="text"></title>




<summary type="text">Contact</summary>

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

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




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





$UN = "NIRCH100";


$Key = "blah blah";

$userNamePassword = $Key . '%' . $UN . ':' . $PW;


curl_setopt($ch, CURLOPT_USERPWD, $userNamePassword);

curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_POSTFIELDS , $theXML);

curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type:application/atom+xml"));

curl_setopt($ch, CURLOPT_HEADER, false);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_FOLLOWLOCATION ,1);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

curl_setopt($ch, CURLOPT_URL, 'https://api.constantcontact.com/ws/customers/username/contacts');

$content = curl_exec($ch);

echo"------------------ ADD CONTACT ------------------";

echo "Connecting to '".str_replace('http://', 'https://', 'http://api.constantcontact.com/ws/customers/NIRCH100/contacts');

echo "And Posting:<pre>\n\n---START---\n". htmlspecialchars($theXML) ."\n---END---\n\n</pre>";

echo "HTTP Response Code '".curl_getinfo($ch, CURLINFO_HTTP_CODE)."'";

echo "Received:<pre>\n\n---START---\n". htmlspecialchars($content) ."\n---END---\n\n</pre><br><br>";


Kindly help me out to find where I am missing as the above code does not add a contact.

The reponse: HTTP Response Code '403'Received:  JBoss Web/2.1.2.GA - Error report


Error 403 typically means that you are trying to access a URI collection that you do not have permission to access. I tested the code that you posted and was able to replicate the error you were receiving. After looking at your code, I noticed the URL you are making the request to is using 'username' in place of your actual username (or the variable you are using to store your username). If you make the modification below, this should resolve your issue.


Try changing:


curl_setopt($ch, CURLOPT_URL, 'https://api.constantcontact.com/ws/customers/username/contacts');




curl_setopt($ch, CURLOPT_URL, 'https://api.constantcontact.com/ws/customers/'.$UN.'/contacts');


I hope this helps, please let us know if you have any other questions.

David J

Developer Portal

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

Visit Page