diff --git a/src/Beanstream/communications/HttpConnector.php b/src/Beanstream/communications/HttpConnector.php index f0d0989..2ec79ff 100644 --- a/src/Beanstream/communications/HttpConnector.php +++ b/src/Beanstream/communications/HttpConnector.php @@ -112,11 +112,12 @@ private function request($http_method = NULL, $url, $data = NULL) if (is_null($res)) { //make sure the result is good to go throw new ConnectorException('Unexpected response format', 0); } - - //check for return errors from the API - if (isset($res['code']) && 1 < $res['code'] && !($req['http_code'] >= 200 && $req['http_code'] < 300)) { + + //check for return errors from the API + $httpCode = curl_getinfo($req, CURLINFO_HTTP_CODE); + if (isset($res['code']) && 1 < $res['code'] && !($httpCode >= 200 && $httpCode < 300)) { throw new ApiException($res['message'], $res['code']); - } + } return $res; }