{"error_key":"unauthorized","error_message":"Unauthorized"}

MrRoyo
Campaign Contributor
0 Votes

I successfully received the access token. And also I can check the token info, token info display these details "{"scopes":["contact_data","campaign_data"]}"

 

But when I try to do any API action I receive this error "{"error_key":"unauthorized","error_message":"Unauthorized"}"

 

I am using following code to create new list:

 

$url = 'https://api.cc.email/v3/contact_lists';

$ch = curl_init();
$data = array(
"name" => "Multiple Countries",
"favorite" => true,
"description" => "List multiple countries"
);

$jsonDataEncoded = json_encode($data);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded);

// Set HTTP Header for POST request
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Cache-Control' => 'no-cache',
'Accept' => 'application/json',
'Content-Type' => 'application/json',
'Authorization' => 'Bearer '.$access_token
));
// Submit the POST request
$result = curl_exec($ch);
$err = curl_error($ch);

// Close cURL session handle
curl_close($ch);
if ($err) {
echo "cURL Error #:" . $err;
} else {

print_r($result);

}

Please let me know what is that issue.

 

3 REPLIES 3
Courtney_E
Employee
0 Votes

Hello MrRoyo,

 

Thank you for reaching out to Constant Contact API Developer Support, and for your patience. My team is here to assist outside software developers with questions about building into Constant Contact's API.

 

It looks like we're working with you directly via email regarding your inquiry, but I wanted to close the loop here as well. If you haven't received our reply, please let us know via email at webservices@constantcontact.com, and reference case number 28232085.


Regards,

Courtney E.
Tier II API Support Engineer

Did I answer your question?
If so, please mark my post as an "Accepted Solution" by clicking the Accept as Solution button in the bottom right hand corner of this post.
Aman_Mamdani
Rookie
0 Votes

Hello, I am also facing the same issue when I am trying to call Constant Contact API.

If you can please help then contact me on my mail id.

Id:- aman.mamdani@spec-india.com

Courtney_E
Employee
0 Votes

Hello Aman_Mamdani,

 

Thank you for reaching out to Constant Contact API Developer Support. My team is here to assist outside software developers with questions about building into Constant Contact's API.

 

An Unauthorized error can be returned either when the access token or API key that you provided is not valid or has expired, or possibly if the request is not formatted correctly.

 

Could you please provide us with the API key that you are using to make the request, as the full request(s) where you are receiving the response error (including URL, headers, and request body), the full response body, as well as timeframes so that we can so that we can better assist you in identifying the root cause of the issue?

 

In order to communicate this information securely, please send it to us via email at webservices@constantcontact.com .


Regards,

Courtney E.
Tier II API Support Engineer

Did I answer your question?
If so, please mark my post as an "Accepted Solution" by clicking the Accept as Solution button in the bottom right hand corner of this post.
Resources
Developer Portal

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

Visit Page

Announcements

API Updates

Join our list to be notified of new features and updates to our V3 API.

Sign Up