Getting error from candleData method of sample code


  • Trying to run the sample code for HDFC as follows:

    /** Historic Data */
    public void getCandleData(SmartConnect smartConnect) throws SmartAPIException, IOException {
    
    	JSONObject requestObejct = new JSONObject();
    	requestObejct.put("exchange", "NSE");
    	requestObejct.put("symboltoken", "1330");
    	requestObejct.put("interval", "ONE_MINUTE");
    	requestObejct.put("fromdate", "2021-04-06 09:45");
    	requestObejct.put("todate", "2021-04-06 10:25");
    
    	String response = smartConnect.candleData(requestObejct);
    	System.out.println(response);
    }
    

    Getting following error:

    No such host is known (apiconnect.angelbroking.comnull)


  • @softice
    This is fixed now. But, the String response of this method is not really helpful to me.
    How did you work around that?


  • Here is the solution. The candleData method tries to fetch REST API end point from Routes by doing a lookup for "api.candle.data" key. But to my surprise the Routes doesn't have any entry for api.candle.data.

    So I updated the Routes.java file with following line,
    put("api.candle.data","/rest/secure/angelbroking/historical/
    v1/getCandleData");

    After this the example code worked. I don't think this code was ever tested before publishing it.

    My Indian mentality of getting things for free lured me to use these APIs but now I understand why are they free. I am acting as their tester. Thinking of switching to Zerodha Kite Connect.