'Facing JSONDecodeError
I am trying to connect to foursquare api to extract certain details but facing JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Below is my code(python3);
import json, requests
#using forsquare api
client_id = 'ABC'
client_secret = 'XYZ'
version = '20220508'
limit = 30
radius = 500
latitude = df_street_pcode.Latitude
longitude = df_street_pcode.Longitude
print(latitude, longitude)
url = 'https://api.foursquare.com/v3/places/search?client_id={}&client_secret={}&ll={},{}&v={}&radius={}&limit={}'\
.format(client_id, client_secret, latitude, longitude, version, radius, limit)
results = requests.get(url).json()
results
Below is the error;
> --------------------------------------------------------------------------- JSONDecodeError Traceback (most recent call
> last) <ipython-input-63-42900a9adb9b> in <module>
> 16 .format(client_id, client_secret, latitude, longitude, version, radius, limit)
> 17
> ---> 18 results = requests.get(url).json()
> 19 results
>
> /usr/local/anaconda/lib/python3.6/site-packages/requests/models.py in
> json(self, **kwargs)
> 887 try:
> 888 return complexjson.loads(
> --> 889 self.content.decode(encoding), **kwargs
> 890 )
> 891 except UnicodeDecodeError:
>
> /usr/local/anaconda/lib/python3.6/json/__init__.py in loads(s,
> encoding, cls, object_hook, parse_float, parse_int, parse_constant,
> object_pairs_hook, **kw)
> 352 parse_int is None and parse_float is None and
> 353 parse_constant is None and object_pairs_hook is None and not kw):
> --> 354 return _default_decoder.decode(s)
> 355 if cls is None:
> 356 cls = JSONDecoder
>
> /usr/local/anaconda/lib/python3.6/json/decoder.py in decode(self, s,
> _w)
> 337
> 338 """
> --> 339 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
> 340 end = _w(s, end).end()
> 341 if end != len(s):
>
> /usr/local/anaconda/lib/python3.6/json/decoder.py in raw_decode(self,
> s, idx)
> 355 obj, end = self.scan_once(s, idx)
> 356 except StopIteration as err:
> --> 357 raise JSONDecodeError("Expecting value", s, err.value) from None
> 358 return obj, end
>
> JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Can you please help me resolve this error. I have very limited knowledge in this area. YOu help is highly appreciated.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
