Join our Ask A Trainer Sessions and Chat With our Experts!

getting 403 errors in response body, but the action requested was performed

SOLVED
Go to solution
WillB120
Campaign Collaborator
0 Votes

I mean, I'm thankful and all that the API call is working, but if I'm getting a spurious error message how am I to know how to handle the response programatically?

 

Currently I'm doing this all in the name of testing.  I started off using the IO/docs interface and all was well.  Once I started integrating the same calls into my development site, I started seeing error responses like so:

 

 { ["headers"]=> array(7) { ["content-type"]=> string(16) "application/json" ["date"]=> string(29) "Sat, 05 Oct 2013 14:46:29 GMT" ["server"]=> string(13) "Mashery Proxy" ["x-mashery-error-code"]=> string(26) "ERR_403_DEVELOPER_INACTIVE" ["x-mashery-responder"]=> string(39) "prod-j-worker-us-east-1d-35.mashery.com" ["content-length"]=> string(3) "168" ["connection"]=> string(5) "Close" } ["body"]=> string(168) "[{ "error_key":"mashery.not.authorized.inactive", "error_message":"The Mashery account associated with this request is not active, or an invalid API key was used." }]" ["response"]=> array(2) { ["code"]=> int(403) ["message"]=> string(9) "Forbidden" } ["cookies"]=> array(0) { } ["filename"]=> NULL }

 

Well, ok, so I've requested to send out a lot of emails so maybe my API access has been suspended...Mashery account is still valid, constant contact account is still valid and making the calls still works on the IO/docs interface.

 

Then I looked at my campaigns in constant contact and lo and behold - they were there.  So the request worked but the error was erroneous.  What gives?

1 ACCEPTED SOLUTION
WillB120
Campaign Collaborator
0 Votes

The API support team got me sorted on this.  Thanks!

 

in case anyone else is experiencing this problem, here's what was going on.  I was using the WordPress wp_http class to create my API call.  Here's a copy 'n paste of the relevant information from the email I got:

 

In this case it ended up being the HTTP request function in WordPress following a location header that is returned in order to provide the URI for a campaign when it is created.

 

In order to fix this, a parameter simply needs to be added to the request for 'redirection' => 0. Here’s the difference in the code:

 

Before:

$result = $request->request( $url, array( 'method' => 'POST', 'headers' => $headers, 'body' => $body) );

 

After

$result = $request->request( $url, array( 'method' => 'POST', 'headers' => $headers, 'body' => $body, 'redirection' => 0) );

View solution in original post

5 REPLIES 5
WillB120
Campaign Collaborator
0 Votes

Um...seriously...anybody?  Help please.

DaveBerard
Employee
0 Votes

Can you provide the code you're using and PM us or email us your API key you're using in the request?  We would need more information to dig into this.  The error message shown indicates that the request had an invalid API key and wasn't actually processed by our servers, it was caught and blocked by our API management proxy (hosted by Mashery).  Either you're sending multiple requests, one that doesn't have all the valid information you need, and the valid request is being processed correctly or something very unexpected is going on.  Either way, we'd need a code sample and your developer information.

Dave Berard
Senior Product Manager, Constant Contact
WillB120
Campaign Collaborator
0 Votes

Thanks

DaveBerard
Employee

Thanks.  Sent this over to the API support staff to take a look at.  We don't have much expertise with that Wordpress module in house, we generally recommend using our PHP wrapper library for PHP development as it eliminates any 3rd party issues and can be fully supported.  Team is going to see if they can trouble shoot this though. 

Dave Berard
Senior Product Manager, Constant Contact
WillB120
Campaign Collaborator
0 Votes

The API support team got me sorted on this.  Thanks!

 

in case anyone else is experiencing this problem, here's what was going on.  I was using the WordPress wp_http class to create my API call.  Here's a copy 'n paste of the relevant information from the email I got:

 

In this case it ended up being the HTTP request function in WordPress following a location header that is returned in order to provide the URI for a campaign when it is created.

 

In order to fix this, a parameter simply needs to be added to the request for 'redirection' => 0. Here’s the difference in the code:

 

Before:

$result = $request->request( $url, array( 'method' => 'POST', 'headers' => $headers, 'body' => $body) );

 

After

$result = $request->request( $url, array( 'method' => 'POST', 'headers' => $headers, 'body' => $body, 'redirection' => 0) );

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