Hi
Can anyone let me know what I've done wrong when trying to send this curl request. I keep getting:-
401 - Access denied due to missing subscription key. Make sure to include subscription key when making requests to an API
// encode params to json
$postData = json_encode($params);
// start the request
$header = array(
'Authorization' => 'bearer '.$access_token,
'Content-Type' => 'application/json',
'Ocp-Apim-Subscription-Key' => '',
);
curl_setopt($ch, CURLOPT_URL, "https://..............azure-api.........................");
curl_setopt($ch, CURLOPT_HTTP_VERSION, 'CURL_HTTP_VERSION_2');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, count($params));
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
// $output contains the output string
$output = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// close curl resource to free up system resources
curl_close($ch);
// store the returned results
$results = json_decode($output);
// if there is an statusCode, check for an error
dd(get_defined_vars());
This morning I've added http_version_2 but I am yet to get this call working! I've obviously set something incorrect but cannot work out for the life of me what I've done wrong!
Cheers
Carl.