We have to test rest API is working or not in magento 2.3 but on my local project work only live site API not working. We have to check site open or not using curl but it's not working. I am not able to find issue what.

Curl code

$your_url = "https://domain.com/rest/all/V1/categories?searchCriteria";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $your_url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_USERPWD,"username:password");
curl_setopt($ch, CURLOPT_FAILONERROR, true);
if (curl_errno($ch)) {
    $error_msg = curl_error($ch);

if (isset($error_msg)) {echo $error_msg;}

Error The requested URL returned error: 401

How to fix this issue?


Add request type -

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
| improve this answer | |
  • It's not working – Devidas Sep 6 '19 at 15:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.