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.
response <- GET(url, add_headers(headers))
I ran the code you provided, but it seems to stop at the specified line, and I'm unable to receive a response. I'm wondering if there's a way to investigate why the code is not progressing further. Any suggestions or guidance would be greatly appreciated.
Can you use a VPN to try a different network connection; this looks like it's timing out. If you know how to use network utilities you can also check with traceroute
I think there is no issue of network as I am trying this same code with Python and Also in Postman, Both working fine. For further code I require this in R but unable to get through.
Is there any setting in R or R studio which can be done?
This is my python code and work perfectly fine :
import requests
import json
headers = {'User-Agent': 'Mozilla/5.0'}
page = requests.get('https://www.nseindia.com/api/option-chain-indices?symbol=NIFTY', headers=headers)
data = json.loads(page.text) # convert json data as object/data frame
data
Code run in just 2 second on count and get correct output