diff --git a/src/Adapter/Guzzle.php b/src/Adapter/Guzzle.php index a7d8ad1c..08c7584e 100644 --- a/src/Adapter/Guzzle.php +++ b/src/Adapter/Guzzle.php @@ -92,7 +92,14 @@ public function request(string $method, string $uri, array $data = [], array $he private function checkError(ResponseInterface $response) { - $json = json_decode($response->getBody()); + $body = (string) $response->getBody(); + + // If first character of the response body is not { then the response is in plain text so need to skip below checks as they fail. + if (strpos($body, '{') !== 0) { + return; + } + + $json = json_decode($body); if (json_last_error() !== JSON_ERROR_NONE) { throw new JSONException();