I'm trying to create Weather app using Retrofit 2 and now I struggle to set the call properly.
Here's the URL that is working:
http://api.openweathermap.org/data/2.5/weather?q=London&APPID=MY_API_KEY
So, I've got my API key and BASE URL is:http://api.openweathermap.org .. This is the method in my Retrofit service:
@GET("/data/2.5/weather?q={city}/&APPID={api}")
Observable<WeatherResponse> getWeather(@Path("city") String city, @Path("api") String api);
And the error I get is:
java.lang.IllegalArgumentException: URL query string "q={city}/&APPID={api}" must not have replace block. For dynamic query parameters use @Query.
So I tried like this:
@GET("/data/2.5/weather?{city}/&APPID={api}")
Observable<WeatherResponse> getWeather(@Query("city") String city, @Path("api") String api);
And I get the same error... Anyone knows what's the deal here, what's wrong with my url?
Do it this way:
There is no need to manually put parameter values in Retrofit - you have to only tell it what are parameters names