I am getting the error bellow when making a request to an api:
HTTP/1.1 401 Unauthorized Server: nginx/1.9.3 Date: Fri, 10 Feb 2017 12:04:35 GMT Content-Length: 0 Connection: keep-alive WWW-Authenticate: BASIC realm="application" X-Powered-By: Undertow 1 Set-Cookie: rememberMe=deleteMe; Path=/ecocashGateway-preprod; Max-Age=0; Expires=Thu, 09-Feb-2017 12:04:35 GMT Set-Cookie: PAYMENTS_CLUSTER=PAY_02; path=/
Here is my php and curl request:
$url = 'https://payonline.econet.co.zw/ecocashGateway-preprod/payment/v1/transactions/amount';
//Initiate cURL.
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
//Attach our encoded JSON string to the POST fields.
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
//Set the content type to application/json
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-length:'.strlen($jsonDataEncoded))
);