Hi , I am using python code to retrieve the json information from themoviedb.org. But not getting the json data in response. I am receiving response code ( 200 : success) but i am not able to get the json data
import requests import json
headers = {'Accept': 'application/json'}
payload = {'api_key': 'Giving a proper key'}
response = requests.get("http://api.themoviedb.org/3/configuration", params=payload, headers=headers) print (response) print (response.json())
Output:
JSONDecodeError Traceback (most recent call last) in () 9 print (response) 10 print (response.url) ---> 11 print (response.json()) 12 13 #response = json.loads(response.text)
C:\Users\upadhsh\AppData\Local\Continuum\Anaconda3\lib\site-packages\requests\models.py in json(self, **kwargs) 810 # used. 811 pass --> 812 return complexjson.loads(self.text, **kwargs) 813 814 @property
C:\Users\upadhsh\AppData\Local\Continuum\Anaconda3\lib\json_init_.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw) 317 parse_int is None and parse_float is None and 318 parse_constant is None and object_pairs_hook is None and not kw): --> 319 return _default_decoder.decode(s) 320 if cls is None: 321 cls = JSONDecoder
C:\Users\upadhsh\AppData\Local\Continuum\Anaconda3\lib\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):
C:\Users\upadhsh\AppData\Local\Continuum\Anaconda3\lib\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)
Es fehlt ein Film oder eine Serie? Logge dich ein zum Ergänzen.
Diesen Eintrag bewerten oder zu einer Liste hinzufügen?
Kein Mitglied?
Antwort von Travis Bell
am 27. Juli 2016 um 11:20
Hi shobhit,
I'm not sure, I have tested this with many JSON parsers and never had a problem. I'm not familiar with the lib you're using, I would double check the documentation and make sure everything is being used properly.
Here's a simple example in Ruby that is working.