AG8004 Error Code while fetching market rates using php curl


  • I am using the following code, but I am getting following response. Please help me out.

    Response:

    stdClass Object ( [success] => [message] => Invalid API Key [errorCode] => AG8004 [data] => )


    Code:

    $URL = "https://apiconnect.angelbroking.com/rest/secure/angelbroking/market/v1/quote/";

    $ch = curl_init($URL);
    $header = array();
    $header[] = 'X-PrivateKey: '.$APIKEY_market;
    $header[] = 'Accept: application/json, application/json';
    $header[] = 'X-SourceID: WEB, WEB';
    $header[] = 'X-ClientLocalIP: '.$_SERVER['REMOTE_ADDR'];
    $header[] = 'X-ClientPublicIP: '.$_SERVER['REMOTE_ADDR'];
    $header[] = 'X-MACAddress: MAC_ADDRESS';
    $header[] = 'X-UserType: USER';
    $header[] = 'Authorization: Bearer '.$JwtToken;
    $header[] = 'Content-Type: application/json';
    
    $str = json_encode(array("mode"=>"LTP","exchangeTokens"=>array("NFO"=>array("150200"))));
    curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    // curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($ch, CURLOPT_POSTFIELDS, $str);
    //curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
    $rest = curl_exec($ch);
    curl_close($ch);
    
    curl_close($ch);
    $result_arr = json_decode($rest);
    print_r($result_arr);
    


  • Hi @virenk1984

    Apologies for delayed response.
    Currently we are supporting for Node JS, Java, Python SDKs. Please reverify the API on the listed SDKs and let us know if the issue still occurs

    Thanks & Regards,
    SmartAPI team