Error in java api while fetching candle data


  • candleData method in SmartConnect class of java is throwing error because of the below issue

    Present code (throwing error):

    public String candleData(JSONObject params) {
    		try {
    			String url = routes.get("api.candle.data");
    			JSONObject response = smartAPIRequestHandler.postRequest(this.apiKey, url, params, accessToken);
    			System.out.println(response);
    			return response.getString("data");
    		} catch (Exception | SmartAPIException e) {
    			System.out.println(e.getMessage());
    			return null;
    		}
    	}
    

    corrected code:

    public JSONArray candleData(JSONObject params) {
    		try {
    			String url = routes.get("api.candle.data");
    			JSONObject response = smartAPIRequestHandler.postRequest(this.apiKey, url, params, accessToken);
    			System.out.println(response);
    			return response.getJSONArray("data");
    		} catch (Exception | SmartAPIException e) {
    			System.out.println(e.getMessage());
    			return null;
    		}
    	}