stanna stanna - 22 days ago 7
Android Question

Retrofit changing the url

I have an issue with retrofit. It changes the URL I'm trying to access.

My interface is:

@GET("/movies/top_rated")
Call<ApiResponse<Movie>> getTopRatedMovies(@Query("api_key") String apiKey);


My client is:

public static final String BASE_URL = "http://api.themoviedb.org/3/";
private static Retrofit retrofit = null;
public static Retrofit getClient(){
if(retrofit == null){
retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build();
}
return retrofit;
}


My issue is that the site I want to retrieve data from is

http://api.themoviedb.org/3/movies/top_rated?api_key=<<your_key>>


but retrofit changes it to

http://api.themoviedb.org/movies/top_rated?api_key=<<your_key>>


Any idea on how to fix this??

Answer

I think that you need to replace:

@GET("/movies/top_rated")

with:

@GET("movies/top_rated")
Comments