GuzzleClientException truncated • Code Workshop
Code Workshop
3/21/2018
Share with
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;
}