omniphx / forrest

A Laravel library for Salesforce
https://omniphx.github.io/forrest/
MIT License
259 stars 120 forks source link

Cannot access Guzzle response despite docs saying you can #317

Closed mbroadhead closed 2 months ago

mbroadhead commented 2 years ago

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.

villfa commented 2 months ago

This issue has been fixed in v2.19.1 by #349. You can now retrieve the raw Guzzle response by adding 'format'=> 'raw'.