Laravel Guzzle client: InvalidArgumentException: "No method configured to handle the form_params configuration key"

I am trying to use the Guzzle client to send API requests and I am getting the error:

InvalidArgumentException: "No method configured to handle the form_params configuration key"

Here's what I've tried:

$response = $this->guzzle->post("https://example.com",[
                'form_params'=> [
                    'client_id'=>$this->client_id,
                    'authorization_code'=>$this->authorization_code,
                    'decoder_query'=> $this->requestQuery
                  ],
            ]
        );

      

$this->requestQuery

is a JSON request.

+3


source to share


3 answers


$response = $this->guzzle->post("https://example.com", [
    'body' => [
        'client_id'         => $this->client_id,
        'authorization_code'=> $this->authorization_code,
        'decoder_query'     => json_encode($this->requestQuery),
    ]
]);

      



with this syntax i get it woking ..

+3


source


you are probably using a version of Guzzle that is up to 6.0. update to the latest version and "form_params" will work fine. I had the same problem since I was in 5.x version

composer require 'guzzlehttp/guzzle:6.0.1'

      

and make sure you update your dependencies:



composer update

      

you will see that it will also go into "guzzlehttp / psr7 (1.0.0)". hope this helps.

+2


source


For me it ended up with the issue with the actual Guzzle package not being correct. It downloaded a version from the cache which was not the PSR7 version.

After clearing the composer cache

php composer.phar clear-cache

I just installed and installed a new composer and fixed the bug by fixing the bug.

+1


source







All Articles