Error - requests.exceptions.JSONDecodeError

Hi in my app https://share.streamlit.io/stockmaniacs/orbpython/main/ORB.py I am getting the folloring error.

requests.exceptions.JSONDecodeError: This app has encountered an error. The original error message is redacted to prevent data leaks. Full error details have been recorded in the logs (if you're on Streamlit Cloud, click on 'Manage app' in the lower right of your app).

Traceback:

File "/home/appuser/venv/lib/python3.7/site-packages/streamlit/script_runner.py", line 430, in _run_script
    exec(code, module.__dict__)File "/app/orbpython/ORB.py", line 19, in <module>
    gainers = nse_get_top_gainers()File "/home/appuser/venv/lib/python3.7/site-packages/nsepython/rahu.py", line 439, in nse_get_top_gainers
    positions = nsefetch('https://www.nseindia.com/api/equity-stockIndices?index=SECURITIES%20IN%20F%26O')File "/home/appuser/venv/lib/python3.7/site-packages/nsepython/rahu.py", line 38, in nsefetch
    output = s.get(payload,headers=headers).json()File "/home/appuser/.conda/lib/python3.7/site-packages/requests/models.py", line 917, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)

My github repositary is at https://github.com/stockmaniacs/orbPython

This code is running fine in my local machine. Can someone plz help?

Hi @stockmaniacs -

If this works locally, but not on Streamlit Cloud, it might be the case that https://www.nseindia.com blocks traffic from Google Cloud. This occasionally happens when sites think people are running web scraping, and unfortunately, there’s no way for us to appeal to them.

Since this error is happening at the JSONDecode step, rather than the actual call, I would dump the requests object to see what the return code was, so that you can hopefully get a better idea of what’s happening. I would guess that you are getting a 4xx error of some sort.

Best,
Randy

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.