Laravel中的Guzzle客户端:InvalidArgumentException:“没有配置任何方法来处理form_params配置密钥”

I am trying to use Guzzle client to post requests to an API, and I am getting an error message saying,

InvalidArgumentException: "No method is configured to handle the form_params config key"

This is what I have 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.

For me, this ended up being an problem with the actual Guzzle package not being correct. It loaded a version from cache that wasn't the the PSR7 version.

After clearing composer cache

php composer.phar clear-cache

I simply did a new composer install and installed just fine, while fixing the error.

$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 am getting it woking..

you are probably using a Guzzle version that's before 6.0. update to the latest version and 'form_params' will work just fine. i had the same issue since i was on 5.x version

composer require 'guzzlehttp/guzzle:6.0.1'

and make sure you update your dependencies:

composer update

you'll then see it'll pull in "guzzlehttp/psr7 (1.0.0)" as well. hope that helps.