I am hitting post
request with json
body. First a tried it using MacOS Terminal and it worked.
curl -H "Content-Type: application/json" -H "Accept:application/json" -H "apiKey:API_KEY" -X POST -k -d '{some_json_data}' https://portal.betterplace.co.in/VishwasAPI/api/public/v2/aadhaar/authenticate
The same request is failing when I am trying it with PHP cURL as follows
$body = [SOME_KEY_VALUE_PAIR];
$str = json_encode($body);
$ch = curl_init();
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $str);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch,CURLOPT_URL,'https://portal.betterplace.co.in/VishwasAPI/api/public/v2/aadhaar/authenticate');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'apiKey' => 'API_KEY',
'Content-Type' => 'application/json',
'Accept' => 'application/json']
);
$res = curl_exec($ch);
echo $res;
curl_close($ch);
With this I got following response :
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access /VishwasAPI/api/public/v2/aadhaar/authenticate on this server.</p>
</body></html>
Can anyone tell me why is this happening plz?