未找到 Retrofit 注释。 @GET 调用中的(参数 #2)
No Retrofit annotation found. (parameter #2) in @GET call
我正在尝试从电影中获取一些数据 api。我尝试像往常一样通过改造进行调用,但第二个参数发生错误。可能是因为字符串参数 videos(在生成 Json 文件的 link 中)不是 "variable" 参数,所以它可能无法识别调用。
服务:
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 的路径中即可。
此外,如果你查看the documentation,路径应该是movie
而不是movies
,ID参数应该是movie_id
而不是[=15] =]
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
);
}
我正在尝试从电影中获取一些数据 api。我尝试像往常一样通过改造进行调用,但第二个参数发生错误。可能是因为字符串参数 videos(在生成 Json 文件的 link 中)不是 "variable" 参数,所以它可能无法识别调用。
服务:
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 的路径中即可。
此外,如果你查看the documentation,路径应该是movie
而不是movies
,ID参数应该是movie_id
而不是[=15] =]
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
);
}