Java 使用不带@PATH的改型API
我使用from是为了显示国家/地区列表,但是如果在使用@PATH时出现错误,我该怎么办Java 使用不带@PATH的改型API,java,android,json,gson,retrofit,Java,Android,Json,Gson,Retrofit,我使用from是为了显示国家/地区列表,但是如果在使用@PATH时出现错误,我该怎么办 public interface ICountryService { String ENDPOINT = "https://restcountries.eu"; @GET("/rest/v1/all") Call<List<Country>> getCountry(@Path("country") String country); } 公共接口ICo
public interface ICountryService {
String ENDPOINT = "https://restcountries.eu";
@GET("/rest/v1/all")
Call<List<Country>> getCountry(@Path("country") String country);
}
公共接口IContryService{
字符串端点=”https://restcountries.eu";
@获取(“/rest/v1/all”)
调用getCountry(@Path(“country”)字符串country);
}
我假设/rest/v1/all
端点是一个国家列表,它不会选择特定的国家。通过添加@Path(“country”)
您正试图组成一个格式为rest/v1/all/someCountry
的url,该url可能无效。国家变量正在url中查找一个{country\u id}。您应该删除@Path
你需要像这样做:
@GET("/rest/v1/all") Call<List<Country>> getCountry();
@GET(“/rest/v1/all”)调用getCountry();
请张贴stacktrace。