CodeIgniter Forums
CURLRequest returns 403 error / shell_exec returns 200 - 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 returns 403 error / shell_exec returns 200 (/showthread.php?tid=80547)



CURLRequest returns 403 error / shell_exec returns 200 - abatrans - 11-15-2021

Environment: PHP: 7.4.9 — CodeIgniter: 4.0.4

Any ideas on this problem:

When I consume an API using the CURLRequest
PHP Code:
$curlClient = \Config\Services::curlrequest();
$response $curlClient->request'POST'$thePath, ['body' => "username=THEUSER&password=THEPASSWORD"'http_errors' => FALSE] ); 

I get a 403 error, however when I execute
PHP Code:
$response shell_exec'curl -d "username=THEUSER&password=THEPASSWORD" -X POST ' $thePath ); 

the api return 200 and the actual data.

A bit more context, the api call is to get a JWT from a Wordpress authorisation plugin.


RE: CURLRequest returns 403 error / shell_exec returns 200 - kenjis - 11-15-2021

It may be the bug.
https://codeigniter4.github.io/CodeIgniter4/installation/upgrade_415.html#curlrequest-header-change

Upgrade 4.1.5.
And see https://codeigniter4.github.io/CodeIgniter4/libraries/curlrequest.html#config-for-curlrequest