0

I am trying to fetch live data from NSE options trading. Below code is not working and the request made is stuck without any response. Any workaround on this?

public void getLiveBankNiftyData() {
        String RESOURCE_PATH = "https://www.nseindia.com/api/option-chain-indices?symbol=BANKNIFTY";
        ResponseEntity<Object[]> responseEntity = restTemplate.getForEntity(RESOURCE_PATH, Object[].class);
        Object[] objects = responseEntity.getBody();
    }
Simon Martinelli
  • 34,053
  • 5
  • 48
  • 82
Devs
  • 23
  • 1
  • 5

2 Answers2

0

i tried this

    // request url
    String url = "https://www.nseindia.com/api/option-chain-indices?symbol=BANKNIFTY";

    // create an instance of RestTemplate
    RestTemplate restTemplate = new RestTemplate();

    // make an HTTP GET request
    String json = restTemplate.getForObject(url, String.class);

    // print json
    System.out.println(json);
  • ranavirkar : Did that work for you? This didn't work for me. I still see the same issue. – Devs Jul 25 '21 at 18:16
  • Yes if we directly hit that URl then we get values in postman, But the concern is different here. My code is not able to load the values. Anyways thank you all. I found a way out. Instead of using RestTemplate I used WebClient and this solved the issue. – Devs Jul 29 '21 at 03:40
0

I found a way out. Instead of using RestTemplate I used WebClient and this solved the issue.

Devs
  • 23
  • 1
  • 5