java - 改造更改 URL

标签 java android retrofit2

我对改造有疑问。它更改了我尝试访问的 URL。

我的界面是:

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

我的客户是:

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;
}

我的问题是我想要从中检索数据的网站是

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

但 Retrofit 将其更改为

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

知道如何解决这个问题吗?

最佳答案

我认为你需要更换:

@GET("/movies/top_rated")

与:

@GET("movies/top_rated")

关于java - 改造更改 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40558414/

相关文章:

java - ThreadPoolExecutor future 任务-Spring bean注入(inject)异常-spring-beans-2.0

java - Sitebricks 是否与 GAE 后端兼容 (Java)

android - 应用程序立即崩溃

android - 如何在 Android 中创建这种类型的 Listview?

android - Retrofit 2 有两条动态路径

gwt - 使用 Java 在 CouchDB 2.0 fauxton 中创建文档

POJO 类型的 Java Set 无法添加元素

安卓 : Permission Denied Error when changing Launcher Activity

android - Retrofit 2 使用 HttpLoggingInterceptor.Level.BODY 在日志中打印空响应主体

android - 避免 '@' 字符在 POST @FormUrlEncoded 请求期间获取 url 编码