I am trying to connect with the web service with PHP and in the web service log, I can see message: Credentials Basic xxxxxxxxxxxxxxxx: rejected.
However If I try to connect with same credentials, on same web service with Postman, it works, and result is returned. In the Postman, in the header I have:
Key: Authorization Value : Basic xxxxxxxxxxxxxxxx
Here is my PHP
$verb = "GET";
$ch = curl_init();
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $verb);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "Basic xxxxxxxxxxxxxxxx");
curl_setopt($ch, CURLOPT_URL, $webServiceUrl);
//curl_setopt($ch, CURLOPT_POST, 1);// set post data to true
curl_setopt($ch, CURLOPT_POSTFIELDS,urlencode($address)); // post data
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$json = curl_exec($ch);
echo 'Curl error: ' . curl_error($ch) .'<hr>'; // This line prints Curl error:
curl_close ($ch);
$obj = json_decode($json);
var_dump($obj); // This line prints NULL
Can anyone on base on this code points me what I am doing wrong?