I am trying to fetch data from the following URL: 'https://www.nseindia.com/api/option-chain-indices?symbol=NIFTY'.
When I access this URL in Google Chrome, it shows me a JSON output. I have successfully retrieved the data using similar configurations in Python and Postman. However, when I try to run the code in R, the console goes into a wait mode and I don't get any response.
I am currently using the following code:
R_Code <- Here
library(curl)
library(jsonlite)
headers <- c('User-Agent' = 'Mozilla/5.0')
req <- curl::new_handle()
curl::handle_setheaders(req, .headers = headers)
curl::handle_setopt(req, ssl_verifypeer = FALSE)
page <- curl::curl_fetch_memory('https://www.nseindia.com/api/option-chain-indices?symbol=NIFTY', handle = req)
data <- jsonlite::fromJSON(rawToChar(page$content))
data
Could you please help me understand why I'm not getting any output in R, while the same code works in other environments?