Join our Ask A Trainer Sessions and Chat With our Great Trainers!

unauthorized response when i do api call

KitoodleCreators
Rookie
0 Votes

I successfully received the access token.

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 contact:

<?php

$access_token = "{token removed}";

$url = 'https://api.cc.email/v3/contacts';
$postdata = '{
"email_address": {
"address": "sibinfotech101@gmail.com",
"permission_to_send": "implicit"
},
"create_source": "Account",
"custom_fields": [
{
"custom_field_id": "0123895a-35cd-11ee-a3a3-fa163eb65cb7",
"value": "Tushar"
},
{
"custom_field_id": "485b7d4a-35dd-11ee-a3a3-fa163eb65cb7",
"value": "9099887766"
},
{
"custom_field_id": "0863b528-35cd-11ee-bcfd-fa163eb65cb7",
"value": "Test Subject"
},
{
"custom_field_id": "0d7f2f92-35cd-11ee-bcfd-fa163eb65cb7",
"value": "Test Message"
}
]
}';

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Cache-Control' => 'no-cache',
'Authorization' => 'Bearer '.$access_token,
'Accept' => 'application/json',
'Content-Type' => 'application/json',
));
$result = curl_exec($ch);
curl_close($ch);
print_r ($result);

exit;

?>

Please let me know what is that issue.

1 REPLY 1
John__B
Employee
0 Votes

Hello KitoodleCreators,

 

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.

 

It looks like we've already followed up with you directly via email, 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 31447618.

 

Please have a look and let us know if you have any other questions!

 

Regards,


John B.
API Support Specialist
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