If I execute the Webservice call with Postman with these parameters:
Content-Type: application/json
Cookie: xxxx
Body: json
The Webservice return successfully a JSON.
So, I generated the code with the Postman and paste it on PHP:
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "url",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "json",
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache",
"content-type: application/json",
"cookie: xxxx",
"postman-token: 7c771f8e-5c87-1d27-64f3-bdb92bba6a19"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
And the Webservice is returning an error 401. But it's working when I execute it on Postman. What am I doing differently from Postman?