Announcing our brand new Campaign Builder!

API v3 submission returns "error_key":"unauthorized"

MIL_FANET
Rookie
0 Votes

I have gone through all the steps to authenticate using OAuth 2.0 server flow as seen in the documentation here https://v3.developer.constantcontact.com/api_guide/server_flow.html

This is all working fine and I'm able to get the access token and refresh the token every hour without problems.

 

But, when I attempt to do a curl post to add/update a contact in a list I get this message returned

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

 

Below is the url and headers I'm using $aTokenValue being the access_token

curl_setopt( $ch, CURLOPT_URL,"https://api.cc.email/v3/contacts");
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('accept: application/json'));
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('authorization: Bearer '. $aTokenValue));
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('cache-control: no-cache'));
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
 

 

any guidance provided would be extremely helpful! Thank you in advance :smileyface:

3 REPLIES 3
MIL_FANET
Rookie
0 Votes

I ended up debugging this with postman and there was an issue with my PHP curl request.  Note to self and others who may see this - test with postman first!

ShandiB
Rookie

 Can you share your successful code please? 

Caleb_A
Employee
0 Votes

Hello Dalena, 

 

My name is Caleb and I am a member of Constant Contact's API Developer Support. 

 

We are happy to see that you were able to verify the cause of this issue. If you have any questions regarding the use of our API please be sure to either reply to this forum post or if the matter contains more private information feel free to send us an email at 'webservices@constantcontact.com' with as much detail pertaining to the issue as available and we will be more than happy to assist you!


Regards,

Caleb A.
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

Polls
How confident are you about the effectiveness of your current marketing strategy?

Top Choice: Not confident at all (74%)