Error when using Retrofit 2

0
  

t = {movieName} & apikey = 11111 "must not have replace block.   dynamic query parameters use @Query.

This error happens when trying to search for a movie by name, I have the following codes, but the error remains:

Retrofit retrofit = new Retrofit.Builder()
        .baseUrl("http://www.omdbapi.com/")
        .addConverterFactory(GsonConverterFactory.create())
        .build();

@GET("?t={movieName}&apikey=11111")
Call<List<MovieResults>> getFilmesByName(@Query("movieName") String movieName);

How to make the movie name dynamic, ie search through what is written within an edittext?

    
asked by anonymous 25.07.2017 / 15:35

1 answer

2

For this situation you should use @Path . Example:

@GET("/?t={movieName}&apikey=11111")
Call<List<MovieResults>> getFilmesByName(@Path("movieName") String movieName);

If you do not want to, there is no need to put the parameter in the URL as you are doing explicitly, just use the @query that is inserted automatically. Here's how it should look:

@GET("/?apikey=11111")
Call<List<MovieResults>> getFilmesByName(@Query("t") String movieName);
    
25.07.2017 / 15:44