The Movie Database-ondersteuning

Hi

Im requesting the default movie to see if i get a response from the api but get the above error message in my rails console (not sure if using rails is relevant in this discussion) when trying this

@response = HTTParty.get("http://api.themoviedb.org/3/movie/550?api_key=api_key).response.body

what would cause the above error code?

3 antwoorden (op pagina 1 van 1)

Jump to last post

Make sure to set a valid accept header. The documentation has examples, and for Ruby using 'rest_client' it looks like so:

require 'rubygems'
require 'rest_client'

headers  = {:accept => "application/json"}
response = RestClient.get "http://api.themoviedb.org/3/movie/550?api_key=###", headers
puts response

Cheers.

thank you for the response, now my output on the screen is [#19, "status_message"=>"Invalid accept header"}, @response=#, @headers={"access-control-allow-origin"=>["*"], "age"=>["0"], "cache-control"=>["public, max-age=172800"], "content-type"=>["application/json;charset=utf-8"], "date"=>["Sat, 22 Dec 2012 22:39:37 GMT"], "etag"=>["\"32ce7fc39a8c593ec2e1e01f5f00527c\""], "server"=>["nginx"], "status"=>["406 Not Acceptable"], "via"=>["1.1 varnish"], "x-cache"=>["MISS"], "x-memc"=>["HIT"], "x-memc-age"=>["94192"], "x-memc-expires"=>["78608"], "x-memc-key"=>["my_key"], "x-varnish"=>["1173684056"], "x-varnish-sid"=>["tm-v-p-1100"], "x-xss-protection"=>["1; mode=block"], "content-length"=>["59"], "connection"=>["Close"]}>, {:accept=>"application/json"}]

Its ok all solved now, thanks. I wasnt setting the headers correctly, HTTparty have a slightly different way of doing it

Film of tv-serie niet gevonden? Meld je aan om deze toe te voegen.

Wereldwijd

s focus op zoekbalk
p open profielmenu
esc sluit een open venster
? open sneltoetsen venster

Op media pagina's

b ga terug (of ga naar bovenliggend item)
e ga naar beweken

Op tv-seizoenspagina's

(rechter pijl) ga naar volgende seizoen
(linker pijl) ga naar vorig seizoen

Op pagina's met tv-series

(rechter pijl) ga naar volgende aflevering
(linker pijl) ga naar vorige aflevering

Op alle afbeeldingspagina's

a open venster afbeelding toevoegen

Op alle bewerkte pagina's

t open vertaalmenu
ctrl+ s verstuur formulier

Op discussiepagina's

n start nieuwe discussie
w Verander kijk status
p privé of openbaar
c schakelen sluiten/openen
a open activiteit
r beantwoord discussie
l ga naar laatste antwoord
ctrl+ enter verstuur uw bericht
(rechter pijl) volgende pagina
(linker pijl) vorige pagina

Instellingen

Want to rate or add this item to a list?

Inloggen