问题描述
我正在使用Youtube API.基本网址是<https://www.googleapis.com/youtube/v3/search/>
I am working on Youtube API.The base URL is <https://www.googleapis.com/youtube/v3/search/>
请求:GET
https://www.googleapis.com/youtube/v3/search?part=snippet&q={search_keyword}&key={API_KEY}
ApiService接口代码-
ApiService Interface code-
public interface ApiService {
@GET("")
Call<YoutubeResponse> searchVideos(@Query("part") String part,
@Query("q") String q,@Query("key") String apiKey);
}
错误: java.lang.IllegalArgumentException:缺少@GET URL或@Url参数.在代码行中
Call<YoutubeResponse> call=service.searchVideos("snippet",s, URLConstants.Youtube_API_KEY);
我是初学者.请帮忙!
推荐答案
从语义上讲,使用 https://www .googleapis.com/youtube/v3/作为您的基本网址,然后在您的服务方法上声明@GET("search/")
.
It's much more semantically correct to use https://www.googleapis.com/youtube/v3/ as your base URL and then declare @GET("search/")
on your service method.
也就是说,如果您真的希望您的基本URL为完整路径,则可以使用@GET(".")
声明最终URL与基本URL相同.
That said, if you really want your base URL to be the full path you can use @GET(".")
to declare that your final URL is the same as your base URL.
这篇关于改型错误-缺少@GET URL或@Url参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!