Closed blorange2 closed 3 years ago
For the error you encountered, $exception->getResponseBody()
returned a serialized object. (The object was created by the JSON error response.)
See the source.
So in this case, you'd unserialize it back into a PHP object.
But there can also be error responses with string response bodies. In those cases, the $exception->getResponseBody()
would return the response body.
Since an SDK client app can't tell if the string should be unserialized or not, and unserialize is a dangerous method (see the docs), I have filed an enhancement request to always return the responseBody as a string. Then the SDK client can handle the JSON if it wants to with no unserialize method needed. Internal ticket DCM-4286
Hi @blorange2 , we have fixed this for the forthcoming 5.5 release. Currently thats the 5.5.0-RC release -- RC means Release Candidate.
To install it: composer require docusign/esign-client:v5.5.0-rc
Please validate from your side and let us know if you still face the issue.
Fixed in release 5.5.0
Please re-open this issue if this is still a problem. Thank you
In my application there is a small chance of error when sending, so I wrap this in a try catch block and catch a standard
Exception
as $exception.So when I do
$exception->getResponseBody()
instead of getting on object, I get a string like so:I want the message attribute but the response body is not an object.
I also tried json decoding it. Any ideas?