Navigation

    SmartAPI Forum
    • Register
    • Login
    • Search
    • Categories
    • Popular
    • Groups
    • FAQs
    • API Docs

    AG8004 Error Code while fetching market rates using php curl

    Test
    0
    2
    11
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • V
      virenk1984 last edited by

      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);
      

      M 1 Reply Last reply Reply Quote 0
      • M
        Moderator_2 @virenk1984 last edited by

        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

        1 Reply Last reply Reply Quote 0
        • First post
          Last post