Note in Guzzle V6.0+, another source of getting the following error may be incorrect use of JSON as an array:
Passing in the "body" request option as an array to send a POST request has been deprecated. Please use the "form_params" request option to send a application/x-www-form-urlencoded request, or a the "multipart" request option to send a multipart/form-data request.
Incorrect:
$response = $client->post('http://example.com/api', [
'body' => [
'name' => 'Example name',
]
])
Correct:
$response = $client->post('http://example.com/api', [
'json' => [
'name' => 'Example name',
]
])
Correct:
$response = $client->post('http://example.com/api', [
'headers' => ['Content-Type' => 'application/json'],
'body' => json_encode([
'name' => 'Example name',
])
])