CodeIgniter Forums
CURLRequest Class Failed to parse json string - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: CURLRequest Class Failed to parse json string (/showthread.php?tid=84861)



CURLRequest Class Failed to parse json string - serialkiller - 11-17-2022

I am using CURLRequest class, to receive data from an API, sometimes I get this message

Code:
<b>Fatal error</b>:  Uncaught CodeIgniter\Format\Exceptions\FormatException: Failed to parse json string, error: &quot;Malformed UTF-8 characters, possibly incorrectly encoded&quot;. in /Users/userName/Sites/MySite/vendor/codeigniter4/framework/system/Format/JSONFormatter.php:41

followed by the stack trace

I understand the message, even if the returned json does not depend on me but on the API, is there a way to still be able to see what is returned from the API in order to understand the problem and possibly report the problem to the API manager?


RE: CURLRequest Class Failed to parse json string - kenjis - 11-17-2022

Add dd() to see the variable before the line of the error.
https://codeigniter4.github.io/CodeIgniter4/testing/debugging.html#dd


RE: CURLRequest Class Failed to parse json string - serialkiller - 11-18-2022

(11-17-2022, 05:55 PM)kenjis Wrote: Add dd() to see the variable before the line of the error.
https://codeigniter4.github.io/CodeIgniter4/testing/debugging.html#dd

but the error line of the JSONFormatter.php file?


RE: CURLRequest Class Failed to parse json string - kenjis - 11-18-2022

(11-18-2022, 02:11 AM)serialkiller Wrote: but the error line of the JSONFormatter.php file?

Yes. Why don't you?

Or run step debugging and stop the execution before the error line.


RE: CURLRequest Class Failed to parse json string - serialkiller - 11-18-2022

(11-18-2022, 03:15 AM)kenjis Wrote:
(11-18-2022, 02:11 AM)serialkiller Wrote: but the error line of the JSONFormatter.php file?

Yes. Why don't you?

Or run step debugging and stop the execution before the error line.

I'll try Smile

Thanks kenjis


RE: CURLRequest Class Failed to parse json string - InsiteFX - 11-19-2022

PHP Code:
dd();
exit(); 



RE: CURLRequest Class Failed to parse json string - serialkiller - 11-28-2022

I'm still here, i tried to put
PHP Code:
dd() 

and also

PHP Code:
dd();
exit; 

before line 41 where the error is reported, but I don't see anything.

I set the value of CI_DEBUG to true as the guide says, but my toolbar is disabled for ajax calls.

What am I doing wrong?


RE: CURLRequest Class Failed to parse json string - kenjis - 11-28-2022

Pass the variable you want to see to dd().