GuzzleClientException truncated

By default, a Guzzle error thrown in Laravel will truncate the response body. When you’re deep in an API integration, this is a productivity killer.

Here’s an easy way to error log the full response body from the API.

try {

$response = $client->request( "POST", $this::$resource, [ 'json' => $item ] );

$body = json_decode( $response->getBody()->getContents() );

return $body;
} catch ( \GuzzleHttp\Exception\ClientException $e) {
// here's the good stuff
Log::error($e->getResponse()->getBody()->getContents());
throw $e;

}
Published