1

How to Retrieve form_params used from a Guzzle BadResponseException (ClientException || ServerException) Object?

I couldn't find it in the documentation.

try {
    $reponse = $this->client->post($uri, [
        'form_params' => $params,
        'headers' => $this->getHeaders()
    ]);
} catch (RequestException $e){
     /// get form_params here without accessing $params
}
Danilo Kobold
  • 2,562
  • 1
  • 21
  • 31

1 Answers1

2

The form encoded parameters can be found on Request Body.

try {
    $reponse = $this->client->post($uri, [
        'form_params' => $params,
        'headers' => $this->getHeaders()
    ]);
} catch (RequestException $e){
     echo (string) $e->getRequest()->getBody();
}
Danilo Kobold
  • 2,562
  • 1
  • 21
  • 31