How do I send parameters for a PUT request in Guzzle 5?
when service ise waiting json raw data
$request = $client->createRequest('PUT', '/yourpath', ['json' => ['key' => 'value']]);
or
$request = $client->createRequest('PUT', '/yourpath', ['body' => ['value']]);
According to the manual,
The body option is used to control the body of an entity enclosing request (e.g., PUT, POST, PATCH).
The documented method of put
'ing is:
$client = new GuzzleHttp\Client();
$client->put('http://httpbin.org', [
'headers' => ['X-Foo' => 'Bar'],
'body' => [
'field' => 'abc',
'other_field' => '123'
],
'allow_redirects' => false,
'timeout' => 5
]);
Edit
Based on your comment:
You are missing the third parameter of the createRequest
function - an array of key/value pairs making up the post
or put
data:
$request = $client->createRequest('PUT', '/put', ['body' => ['foo' => 'bar']]);