ZeevG/python-forecast.io

No JSON object could be decoded

Closed this issue · 2 comments

Hello. When I run your example script, I get this error :

Traceback (most recent call last):
  File "main.py", line 16, in <module>
    forecast = forecastio.load_forecast(api_key, lat, lng)
  File "/usr/local/lib/python2.7/dist-packages/forecastio/api.py", line 41, in load_forecast
    return manual(baseURL, callback=callback)
  File "/usr/local/lib/python2.7/dist-packages/forecastio/api.py", line 51, in manual
    return get_forecast(requestURL)
  File "/usr/local/lib/python2.7/dist-packages/forecastio/api.py", line 61, in get_forecast
    json = forecastio_reponse.json()
  File "/usr/lib/python2.7/dist-packages/requests/models.py", line 741, in json
    return json.loads(self.text, **kwargs)
  File "/usr/lib/python2.7/json/__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.7/json/decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python2.7/json/decoder.py", line 384, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

Of course, I use the my API Key

ZeevG commented

Did you manage to sort this out? It's possible this is something at the HTTP API's end. No JSON object could be decoded means that the HTTP response did not return a valid JSON object.

Alternatively, you could be entering invalid parameters and the HTTP response is a 400?

Fixed : I had a bad way of importing my key from a file. Sorry for the trouble !