body
Summary
The body
option is used to control the body of an entity enclosing request (e.g., PUT, POST, PATCH).
Types
- string
fopen()
resourcePsr\Http\Message\StreamInterface
Default
None
Constant
GuzzleHttp\RequestOptions::BODY
This setting can be set to any of the following types:
string
// You can send requests that use a string as the message body.
$client->request('PUT', '/put', ['body' => 'foo']);
resource returned from
fopen()
// You can send requests that use a stream resource as the body.
$resource = fopen('http://httpbin.org', 'r');
$client->request('PUT', '/put', ['body' => $resource]);
Psr\Http\Message\StreamInterface
// You can send requests that use a Guzzle stream object as the body
$stream = GuzzleHttp\Psr7\stream_for('contents...');
$client->request('POST', '/post', ['body' => $stream]);
Note
This option cannot be used with form_params
, multipart
, or json