The Movie Database Support

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)

1 reply (on page 1 of 1)

Jump to last post

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.

require 'rest_client'
api_key = "###"
request = RestClient.get 'http://api.themoviedb.org/3/configuration', { :accept => 'application/json', :params => { :api_key => api_key } }
JSON.parse(request)

2.1.5 :009 > require 'rest_client'
=> true
2.1.5 :010 > api_key = "###"
=> "###"
2.1.5 :011 > request = RestClient.get 'http://api.themoviedb.org/3/configuration', { :accept => 'application/json', :params => { :api_key => api_key } }
=> "{\"images\":{\"base_url\":\"http://image.tmdb.org/t/p/\",\"secure_base_url\":\"https://image.tmdb.org/t/p/\",\"backdrop_sizes\":[\"w300\",\"w780\",\"w1280\",\"original\"],\"logo_sizes\":[\"w45\",\"w92\",\"w154\",\"w185\",\"w300\",\"w500\",\"original\"],\"poster_sizes\":[\"w92\",\"w154\",\"w185\",\"w342\",\"w500\",\"w780\",\"original\"],\"profile_sizes\":[\"w45\",\"w185\",\"h632\",\"original\"],\"still_sizes\":[\"w92\",\"w185\",\"w300\",\"original\"]},\"change_keys\":[\"adult\",\"air_date\",\"also_known_as\",\"alternative_titles\",\"biography\",\"birthday\",\"budget\",\"cast\",\"certifications\",\"character_names\",\"created_by\",\"crew\",\"deathday\",\"episode\",\"episode_number\",\"episode_run_time\",\"freebase_id\",\"freebase_mid\",\"general\",\"genres\",\"guest_stars\",\"homepage\",\"images\",\"imdb_id\",\"languages\",\"name\",\"network\",\"origin_country\",\"original_name\",\"original_title\",\"overview\",\"parts\",\"place_of_birth\",\"plot_keywords\",\"production_code\",\"production_companies\",\"production_countries\",\"releases\",\"revenue\",\"runtime\",\"season\",\"season_number\",\"season_regular\",\"spoken_languages\",\"status\",\"tagline\",\"title\",\"translations\",\"tvdb_id\",\"tvrage_id\",\"type\",\"video\",\"videos\"]}"
2.1.5 :012 > JSON.parse(request)
=> {"images"=>{"base_url"=>"http://image.tmdb.org/t/p/", "secure_base_url"=>"https://image.tmdb.org/t/p/", "backdrop_sizes"=>["w300", "w780", "w1280", "original"], "logo_sizes"=>["w45", "w92", "w154", "w185", "w300", "w500", "original"], "poster_sizes"=>["w92", "w154", "w185", "w342", "w500", "w780", "original"], "profile_sizes"=>["w45", "w185", "h632", "original"], "still_sizes"=>["w92", "w185", "w300", "original"]}, "change_keys"=>["adult", "air_date", "also_known_as", "alternative_titles", "biography", "birthday", "budget", "cast", "certifications", "character_names", "created_by", "crew", "deathday", "episode", "episode_number", "episode_run_time", "freebase_id", "freebase_mid", "general", "genres", "guest_stars", "homepage", "images", "imdb_id", "languages", "name", "network", "origin_country", "original_name", "original_title", "overview", "parts", "place_of_birth", "plot_keywords", "production_code", "production_companies", "production_countries", "releases", "revenue", "runtime", "season", "season_number", "season_regular", "spoken_languages", "status", "tagline", "title", "translations", "tvdb_id", "tvrage_id", "type", "video", "videos"]}

Can't find a movie or TV show? Login to create it.

Global

s focus the search bar
p open profile menu
esc close an open window
? open keyboard shortcut window

On media pages

b go back (or to parent when applicable)
e go to edit page

On TV season pages

(right arrow) go to next season
(left arrow) go to previous season

On TV episode pages

(right arrow) go to next episode
(left arrow) go to previous episode

On all image pages

a open add image window

On all edit pages

t open translation selector
ctrl+ s submit form

On discussion pages

n create new discussion
w toggle watching status
p toggle public/private
c toggle close/open
a open activity
r reply to discussion
l go to last reply
ctrl+ enter submit your message
(right arrow) next page
(left arrow) previous page

Settings

Want to rate or add this item to a list?

Login