cancel
Showing results for 
Search instead for 
Did you mean: 

Getting 403 Code from API on add contact

Occasional Participant

Getting 403 Code from API on add contact

Extremely odd,

 

I'm sending this

 

https://api.constantcontact.com/v2/contacts?api_key=API_KEY&action_by=ACTION_BY_OWNER

{"email_addresses":[{"email_address":"xxxxx@hotmail.co.nz"}],"lists":[{"id":"LIST#","status":"ACTIVE"}]}

 

And when I try it via the API Tester, it works fine and inserts the contact / list.

 

When I try it using a PHP curl call I get a 403 Forbidden

 

Same API Key same access token.

 

Do you know why it kicks me out in PHP?

 

 

< HTTP/1.1 403 Forbidden
< Cache-Control: private, no-cache, no-store, max-age=0, must-revalidate, no-cache="Set-Cookie"
< Content-Type: application/json;charset=ISO-8859-1
< Date: Thu, 24 Dec 2015 20:54:49 GMT
< Pragma: no-cache
< Server: Apache
< Vary: Accept-Encoding,User-Agent
< WWW-Authenticate: Bearer error='http.status.forbidden',
< X-Mashery-Responder: prod-j-worker-us-east-1e-105.mashery.com
< X-Powered-By:
< transfer-encoding: chunked
< Connection: keep-alive
<
* Connection #0 to host api.constantcontact.com left intact
* Closing connection #0
[{"error_key":"user.privilege.forbidden","error_message":"You don't have permission to perform this action; please see your account owner."}]

 

 

 

8 REPLIES 8
CTCT Employee

Re: Getting 403 Code from API on add contact

Hi Jason,

 

My best guess here is that the curl call you're making isn't sending the access token properly in the header. You could test this by adding the access token to the URL, so it would be

 

https://api.constantcontact.com/v2/contacts?api_key=API_KEY&action_by=ACTION_BY_OWNER&access_token=XXXX

 

XXXX should be replaced with your token, of course.

 

Best Regards,

Shannon Wallace

Partner API Support Engineer

Occasional Participant

Re: Getting 403 Code from API on add contact

Unfortunately, even adding that to the end stil says 

    You don't have permission to perform this action; please see your account owner.

 

 

I can update contants, remove from lists, add to lists. but the one thing I cannot do via a curl call is create new contacts.

 

Any more ideas?

CTCT Employee

Re: Getting 403 Code from API on add contact

Hi Jason,

 

The error message suggests that the access token you're using might be an alternate login for an account with more than one user, but I'm not aware of any user types that can update contacts, but not add them.

 

My last idea for you to try on your own is to have you make sure that the resource URL you're making the API call to does NOT end with a trailing slash ( / ). We do have an issue with mapping user privileges when that trailing slash is included. If the URL you're making the request to does have a slash after 'contacts' like below, remove it and try again. I don't see that trailing slash in the URL of your previous post (https://api.constantcontact.com/v2/contacts?api_key=API_KEY&action_by=ACTION_BY_OWNER), but this might cause that error:

 

https://api.constantcontact.com/v2/contacts/?api_key=API_KEY&action_by=ACTION_BY_OWNER

 

If that doesn't seem to be the issue, I'd like to troubleshoot on my side. Could you email webservices@constantcontact.com and reference this forum post? I'll need the access token you're using, and the JSON request body you're sending over, if possible.

 

Thanks!

 

Best Regards,

Shannon Wallace

Partner API Support Engineer

 

Occasional Participant

Re: Getting 403 Code from API on add contact

Email Sent, please use the 2nd one as I sent the wrong json data.

Occasional Participant

Re: Getting 403 Code from API on add contact

And the solution is!

 

Because I'm sending a PUT request instead of a POST request.

/sigh.

 

So it's solved.  PUT request returns Forbidden.

Highlighted
CTCT Employee

Re: Getting 403 Code from API on add contact

Thanks for the follow up! Sorry for the less than helpful error message there.

 

Best Regards,

Shannon Wallace

Partner API Support Engineer

Occasional Organizer

Re: Getting 403 Code from API on add contact

There is no mention of a needed access token on this page, please update the documentation to reflect that, and to show how to add it.

http://developer.constantcontact.com/docs/bulk_activities_api/bulk-activities-import-contacts.html?m...

Moderator

Re: Getting 403 Code from API on add contact

Hi @NeilE83,

 

I have sent this request along to the person in charge of our documentation and they will review the request.


Regards,
Jimmy D.
Tier II API Support Engineer