0

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);
curl_exec($ch);
if (curl_errno($ch)) {
    $error_msg = curl_error($ch);
}
curl_close($ch);

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

Error The requested URL returned error: 401

How to fix this issue?

1 Answer 1

0

Add request type -

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
1
  • It's not working
    – Devidas
    Sep 6, 2019 at 15:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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