![]() |
How can get Response from API when status is 4xx using Curl library - 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: How can get Response from API when status is 4xx using Curl library (/showthread.php?tid=91031) |
How can get Response from API when status is 4xx using Curl library - mylastof - 06-06-2024 some API has set 400, 401 etc if have error in username or other param in CI4 (v4.4.8) I cant get response for this. any idea? RE: How can get Response from API when status is 4xx using Curl library - kenjis - 06-06-2024 Are you talking about CURLRequest? See https://codeigniter.com/user_guide/libraries/curlrequest.html#http-errors RE: How can get Response from API when status is 4xx using Curl library - mylastof - 06-07-2024 (06-06-2024, 08:55 PM)kenjis Wrote: Are you talking about CURLRequest? yes, its about it. but how to get response from API when its status code is 400, 401 I use try-catch, but in catch cant use like Guzzle PHP Code: try { RE: How can get Response from API when status is 4xx using Curl library - SonzoXide - 06-07-2024 PHP Code: $response = $client->request('GET', '/api-endpoint', ['http_errors' => false]); you may try add http_errors => false, like example above to get the response from API. RE: How can get Response from API when status is 4xx using Curl library - mylastof - 06-08-2024 (06-07-2024, 09:46 AM)SonzoXide Wrote: many thanks |