-
Notifications
You must be signed in to change notification settings - Fork 299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Weird Unable to parse response as JSON
#268
Comments
I solved it like this: try {
|
Hello, @Dadinos Fatal error: Uncaught Exception: Unable to parse response as JSON in C:\wamp64\alexya\vendor\nategood\httpful\src\Httpful\Handlers\JsonHandler.php on line 30 |
Something like this:
|
I know this may be an old thread, but I thought I'd suggest something. If your request fails to give you properly formed json data, you could simply make a second request with ->autoParse(false) and then inspect that result text for error messages. The example code below was for Symfony 4.
|
I have a controller that sends a get request and then tries to parse the response as a JSON. However, requesting it through the browser returns a valid JSON object. I'm getting a 500 error that says 'Exception: Unable to parse response as JSON' and points to
JsonHandler.php
. I looked through the file and it is because the body is empty. I am confused since the request url is valid and returns a valid JSON object.I'm using
$APIResponse = \Httpful\Request::get($url, 'application/json')->send();
in the controller, however this never returns anything since it gets blocked when it hitsJsonHandler.php
. I feel like somewhere between the request is sent and the JsonHandler, the body is being malformed?The text was updated successfully, but these errors were encountered: