The Movie Database Support

Hi everyone, I am developing a simple app for learning purposes, which uses the movie db APIs. The code i am using to perform http requests to is the following:

   HttpURLConnection connection;
    try {
        /* starting http request */
        connection = (HttpURLConnection) url.openConnection();

        /* reading the response */
        BufferedReader rd;
        if(connection.getResponseCode() != 200){
            rd = new BufferedReader(new InputStreamReader(connection.getErrorStream()));
        } else {
            rd = new BufferedReader(new InputStreamReader(connection.getInputStream()));

        StringBuilder content = new StringBuilder();
        String line;
        while ((line = rd.readLine()) != null) {

        /* returning it to the caller */
        return content.toString();
    } catch (IOException e){
        Log.v(TAG, "Problems connecting to the server: " + e.getMessage());
        return "";

This code is working perfectly to retrieve a list of movies, with a url like:[your api key]&page=1

But to retrieve the list of videos for a movie, so a url like:[your api key]

is not working! getResponseCode() returns to me 404 and in the error stream i read:

{“status_code”:34,“status_message”:“The resource you requested could not be found.”}

The odd thing is that if with the debugger i copy the url the code is working on and copy it on my browser it works as expected (showing me the json response).

Any chance someone can help me with this issue?

2 replies (on page 1 of 1)

Jump to last post

I solved it. It was the connection.setDoOutput(true)

Hi @wellsaid2, happy to hear it. Hopefully that can help other people in the future!