Search code examples
javaapivs-web-application-project

com.omdbapi.OmdbConnectionErrorException error


I have written a code in java by using which I am accessing the movie details in IMDB website. For that, I am using OMDB API in java but I am getting connection error why I don't understand because in INFO of output it shows the details about movie.

CODE:

Omdb o = new Omdb();
    Movie movie= o.searchOneMovie("star wars");
    System.out.print(movie);

ERROR:

INFO: executing GET http://www.omdbapi.com/?t=star+wars HTTP/1.1
Mar 13, 2017 5:09:18 PM com.omdbapi.Omdb resultToJson
INFO: received {"Title":"Star Wars: Episode IV - A New   Hope","Year":"1977","Rated":"PG","Released":"25 May 1977","Runtime":"121 min","Genre":"Action, Adventure, Fantasy","Director":"George Lucas","Writer":"George Lucas","Actors":"Mark Hamill, Harrison Ford, Carrie Fisher, Peter Cushing","Plot":"Luke Skywalker joins forces with a Jedi Knight, a cocky pilot, a wookiee and two droids to save the galaxy from the Empire's world-destroying battle-station, while also attempting to rescue Princess Leia from the evil Darth Vader.","Language":"English","Country":"USA","Awards":"Won 6 Oscars. Another 50 wins & 28 nominations.","Poster":"https://images-na.ssl- images-amazon.com/images/M/MV5BYzQ2OTk4N2QtOGQwNy00MmI3LWEwNmEtOTk0OTY3NDk2MGJkL2ltYWdlL2ltYWdlXkEyXkFqcGdeQXVyNjc1NTYyMjg@._V1_SX300.jpg","Metascore":"92","imdbRating":"8.7","imdbVotes":"963,318","imdbID":"tt0076759","Type":"movie","Response":"True"}
 Exception in thread "main" com.omdbapi.OmdbConnectionErrorException:        Unrecognized field "Metascore" (class com.omdbapi.Movie), not marked as ignorable (15 known properties: , "Plot", "Response", "Genre", "Rated",  "imdbVotes", "Director", "Poster", "Writer", "Title", "Runtime", "Year", "imdbID", "Released", "Actors", "imdbRating"])
at [Source: java.io.StringReader@dd3b207; line: 1, column: 40] (through  reference chain: com.omdbapi.Movie["Metascore"])
at com.omdbapi.Omdb.getOneMovie(Omdb.java:65)
at com.omdbapi.Omdb.searchOneMovie(Omdb.java:54)
at test.searchMovie.main(searchMovie.java:15)

Solution

  • You are expecting the Metascore field, but it isn't there - either remove it or mark as ingorable. The response from IMDB is fine - no error there, the is error in your code