Right now if you are using a guzzle middleware that reads content (or something else that also reads content), you will get empty string when you call getBody()->getContents() and as a consequence a json decode error, because the stream has already been read
Sample code that reads the body before returning the response:
$stack = HandlerStack::create();
$stack->push(
Middleware::log(
$this->logger,
new MessageFormatter(MessageFormatter::DEBUG)
)
);
$this->client = (new Factory())->withApiKey($this->apiKey)
->withOrganization($this->organization)
->withHttpClient(new Client(['handler' => $stack]))
->make();
Solution:
Use StreamInterface::_toString(), because it must attempt to seek to the beginning of the stream
Right now if you are using a guzzle middleware that reads content (or something else that also reads content), you will get empty string when you call getBody()->getContents() and as a consequence a json decode error, because the stream has already been read
Sample code that reads the body before returning the response:
Solution:
Use StreamInterface::_toString(), because it must attempt to seek to the beginning of the stream