Как получить параметры формы, отправленные на исключение Guzzle? - PullRequest
0 голосов
/ 03 апреля 2020

Как извлечь form_params из объекта Guzzle BadResponseException (ClientException || ServerException) Объект?

Я не смог найти его в документации.

try {
    $reponse = $this->client->post($uri, [
        'form_params' => $params,
        'headers' => $this->getHeaders()
    ]);
} catch (RequestException $e){
     /// get form_params here without accessing $params
}

1 Ответ

1 голос
/ 03 апреля 2020

Закодированные в форме параметры можно найти в теле запроса.

try {
    $reponse = $this->client->post($uri, [
        'form_params' => $params,
        'headers' => $this->getHeaders()
    ]);
} catch (RequestException $e){
     echo (string) $e->getRequest()->getBody();
}
...