title: How to connect to TMDB api
body: <p>Here is my api key: 7b5e30851a9285340e78c201c4e4ab99  </p>
  
  <p>And I am trying to connect to TMDB api: here is my code: </p>
  
  <pre><code>package movieDBapiconnnection;
  
  import java.io.BufferedReader;
  import java.io.InputStreamReader;
  import java.net.HttpURLConnection;
  import java.net.URL;
  
  public class connection {
  
      public static void main(String[] args) throws Exception{
              URL url = new URL("http://api.themoviedb.org/3/movie/550?api_key=7b5e30851a9285340e78c201c4e4ab99/3/movie/550");
              HttpURLConnection con = (HttpURLConnection) url.openConnection();
              con.setDoOutput(true);
              con.setRequestMethod("GET");
              con.setRequestProperty("Content-Type", "application/json");
  
              BufferedReader br = new BufferedReader(new InputStreamReader((con.getInputStream())));
  
              String output;
              System.out.println("Output from Server .... \n");
              while ((output = br.readLine()) != null) {
                  System.out.println(output);
              }
      }
  }
  </code></pre>
  
  <p>But it always showing me the error that:  </p>
  
  <p>Exception in thread "main" java.io.IOException: Server returned HTTP response code: 401 for URL: <a href="http://api.themoviedb.org/3/movie/550?api_key=7b5e30851a9285340e78c201c4e4ab99/3/movie/550" rel="nofollow">http://api.themoviedb.org/3/movie/550?api_key=7b5e30851a9285340e78c201c4e4ab99/3/movie/550</a>
      at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
      at movieDBapiconnnection.connection.main(connection.java:17)</p>