android - 未找到改造注释。@GET 调用中的(参数 #2)
问题描述
我正在尝试从电影 api 中获取一些数据。我尝试像往常一样进行改造,但第二个参数出现错误。这可能是因为字符串参数视频(在生成 Json 文件的链接中)它不是“变量”参数,所以它可能无法识别调用。
服务:
public interface Service {
@GET("/3/movies/{id}")
Call<TrailerResponse> getVideos (
@Path("id") int id,
String videos,
@Query("api_key") String apiKey,
@Query("language") String language
);
}
加载(我认为指定的 getVideos 中的变量并不重要)
public static List<Videos> load() {
Service apiService = Client.getClient().create(Service.class);
Call<TrailerResponse> call;
call = apiService.getVideos(ID, VIDEOS, API_KEY, LANGUAGE);
if(call == null){
return null;
}
解决方案
看起来您需要删除videos
参数,并将其添加到 url 的路径中。
此外,如果您查看文档,路径应该是movie
而不是movies
,并且 ID 参数应该是movie_id
而不是id
public interface Service {
@GET("/3/movie/{id}/videos")
Call<TrailerResponse> getVideos (
@Path("movie_id") int id,
@Query("api_key") String apiKey,
@Query("language") String language
);
}
推荐阅读
- python - 购物清单将“退出”字母添加到列表中,而不是打破 while 循环并退出程序
- winapi - 如果 CoInitialize/Ex 失败,是否需要 CoUninitialize?
- javascript - 如何将所有控制台日志获取到不和谐的文本/嵌入消息?
- python - 调用多个函数的更 Pythonic 方式
- maven - 如何为我的 Google 函数覆盖 GOOGLE_ENTRYPOINT?
- yaml - 如何从具有用户级凭据的用户禁用 Web 部署 Azure 功能
- terminal - 从 http://localhost:9292/ 获取源索引
- android - 无法将 Android Studio 连接到 Pixel 2
- python - 从大型 XML 中提取标签到 csv
- snowflake-cloud-data-platform - 授予对 Snowflake 中特定未来表的访问权限