forrest icon indicating copy to clipboard operation
forrest copied to clipboard

Cannot access Guzzle response despite docs saying you can

Open mbroadhead opened this issue 2 years ago • 0 comments

The docs mention:

Raw response output

By default, this package will return the body of a response as either a deserialized JSON object or a SimpleXMLElement object.

There might be times, when you would rather handle this differently. To do this, simply use any format other than 'json' or 'xml' and the code will return a Guzzle response object.

$response = Forrest::sobjects($resource, ['format'=> 'none']);
$content = (string) $response->getBody(); // Guzzle response

the code will return a Guzzle response object

This is actually not the case. If you pass ['format' => 'none'], the formatter gets set to an instance of BaseFormatter, which returns (string) $response->getBody(). So I don't currently see a way to get the raw Guzzle response.

It would be nice if this actually worked the way the docs describe. I'm trying to download large files from Salesforce and would prefer to get back a guzzle response stream rather than the entire contents of the file as a string in memory.

mbroadhead avatar Apr 22 '22 00:04 mbroadhead