bigcommerce-api-php
bigcommerce-api-php copied to clipboard
Exception when handling 404 responses with JSON content in body
Connection.php L212 If the response body of a request with 404 status has JSON content, the library throws an exception instead of ClientError.
Cause: Connection::handleResponse() decodes the response body without checking the response status and then tries to create a ClientError object using the decoded response body object. ClientError is expecting a string as argument but gets an object instead and thus throws an Error
Wow this is old. I got the same issue (but with a different error). Whenever the body is not JSON and you're using JSON, it will pass an incorrect argument to ClientError and crash. This does not happen if you're using Xml, as the body is returned raw.
This could be easily fixed by calling json_decode after the status check. I can make a pull request