Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Error 301  (Read 2236 times)

0 Members and 1 Guest are viewing this topic.

Wylex

  • Newbie
  • *
  • Posts: 5
    • View Profile
Error 301
« on: April 16, 2016, 07:56:33 pm »
Well, I keep trying to use the API I mentioned on the last post https://www.themoviedb.org/ but... beginnings were never easy I guess.

I have another problem now, here's the thing: I'm trying to use the search/movie function but again even if on my browser works fine it doesn't when I try to program it.

       
sf::Http http("http://api.themoviedb.org");

sf::Http::Request request;
request.setMethod(sf::Http::Request::Get);
request.setUri("/3/search/movie/?api_key=###&query=Interstellar");
 

According to the documentation, this function needs the api key and the name of the movie you're looking for witch must be a "CGI escaped string". If I'm not wrong, the escaped string shouldn't change anything if I'm looking for a one word movie tittle (in this case Interstellar).

Anyway, with the code above, the status of the request is 301 (Moved permanently). I've try to look why it isn't working but I just don't know why nor how I can fix that. Any idea? Thanks

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11016
    • View Profile
    • development blog
    • Email
Re: Error 301
« Reply #1 on: April 16, 2016, 09:06:16 pm »
301 means, as you figured out yourself, that the content has been permanently moved and you also get the new location. Now a browser will automatically adjust, which is why in your browser it seems to work fine.

I've quickly run Wireshark and there it became clear that your specified path is not correct and thus you get redirected.

Your code:
 request.setUri("/3/search/movie/?api_key=###&query=Interstellar");

Working/redirected code:
 request.setUri("/3/search/movie?api_key=###&query=Interstellar");
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Wylex

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Error 301
« Reply #2 on: April 17, 2016, 12:31:15 am »
Thanks again, works fine now.