How to solve the error "Authentication credentials were not provided" while running a CURL get request in php?

I am trying to hit a CURL "GET" request in php but getting the error as "Authentication credentials were not provided". So I cannot understand for which exact reason, the error is showing. Can anyone help?

$api_token = "test";
    $question_id = "test1";
    $organization_id = "test2";
    $thumbnail_file_path = "";

    $request_headers[]='Authorization: f'.$api_token;
    $request_headers[]='Content-Type: application/json';

    // return $payloadName;

    $process = curl_init();
    curl_setopt($process, CURLOPT_HTTPHEADER, $request_headers);
    curl_setopt($process, CURLOPT_URL,$url);
    curl_setopt($process, CURLOPT_RETURNTRANSFER,true);
    curl_setopt($process, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    $output = curl_exec($process);


    echo $output;
    $err = curl_error($process);
    // get info about the request
    $info = curl_getinfo($process);

>Solution :

Are you sure f in Authorization header is necessary? Looks like a typo

Leave a Reply