Jose Jose - 5 days ago 6
Java Question

Consuming apis with Retrofit without @PATH


I'm consuming from https://restcountries.eu/rest/v1/all in order to
show a country list, but AS throw me an error when using the @PATH,
what can i do?


public interface ICountryService {

String ENDPOINT = "https://restcountries.eu";


@GET("/rest/v1/all")
Call<List<Country>> getCountry(@Path("country") String country);


}

Answer

The country variable is looking for a {country_id} inside the URL. You should remove the @Path.

You need to do it like:

@GET("/rest/v1/all") Call<List<Country>> getCountry();
Comments