Rob Allen

Increase truncated body in a Guzzle exception

2024-9-24

Rob

When Guzzle throws BadResponseException, the message includes information about the method, URL response code and then a truncated part of the body. For example: "Client error: `GET https://dev.clientproject.com:4444/oauth2/authorize?client_id=983e98d2fab8756a&scope=scope&response_type=code&redirect_uri=%2Fhome&code_challenge=some_code_challenge_here` resulted in a `400 Bad Request` response: {"error":"invalid_request","error_description":"The request is missing a required parameter, includes an invalid parame (truncated...) To retrieve the full text of the body, you grab it from the response property of the exception: $body = $e->getResponse()->getBody()->getContents(); Changing the truncation limit If you want… continue reading.