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 Status 401 - Unable to authenticate user myaccount

Occasional Participant

HTTP Status 401 - Unable to authenticate user myaccount


I'm trying to communcate with ConstantConact API using PHP  below:

$ConstantContact = new Constantcontact("basic", myapi, myusername, mypass);


if i put wrong credentail, I got 401 error. This is OK, i understand this error but this gets diplay on my page. I want to catch the error and show some user friendly error message to user on page.


try {
        // Create ConstantContact object and call to ConstantContact api
       $ConstantContact = new Constantcontact("basic", myapi, myusername, mypass);
        // Get ConstantContact's account lists
        return $ConstantContact->getLists();
    } catch(Exception $ex) {


I'm not able to catch the error and i always get the ConstantConact error list on whole page like below:



Can you please help me that if my user enter invalid credential and error is returned back then how can i catch this error and show my user friendly errro message to user? Thanks





Thank you for reaching out to us! I'd like to suggest that you actually check out developer.constantcontact.com or e-mail webservices@constantcontact.com for API related questions. We have a team dedicated and trained to handle these types of inquiries and you'll have much better luck getting your questions answered. Thank you so much!



If you find my post helpful, and it answers your question, please mark it as an "Accepted Solution"

I put up a respone to your thread in the Getting Started section here: http://community.constantcontact.com/t5/Getting-Started-with-API-s/HTTP-Status-401-Unable-to-authent...


Dave Berard
Senior Product Manager, Constant Contact
Developer Portal

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

Visit Page