Login successful. Access Token:
{“data”:{“candles”:},“status”:“success”}
Not getting Intraday Data for below call.
String intraurl = "https://api.upstox.com/v3/historical-candle/intraday/MCX_FO%7C450659/minutes/1";
HttpClient httpClient = HttpClient.newHttpClient();
HttpRequest httpRequest = HttpRequest.newBuilder()
.uri(URI.create(intraurl))
.header("Content-Type", "application/json")
.header("Accept", "application/json")
.header("Authorization", "Bearer {accessToken}")
.build();
try {
JSONObject jsonObject;
JSONObject Ddata;
//JSONArray Ccandles = new JSONArray();
HttpResponse<String> httpResponse = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString());
// Check the response status
if (httpResponse.statusCode() == 200) {
jsonObject = new JSONObject(httpResponse.body());
Ddata = jsonObject.getJSONObject("data");
Ccandles = Ddata.getJSONArray("candles");
System.out.println(jsonObject);
System.out.println(Ccandles);
Ccandleslength = Ccandles.length();
if (Ccandleslength == 0)
{
System.err.println("Not getting Intraday Data.");
}