Reputation: 3281
I am using Retrofit2 and RxJava in my application. I have to pass multiple values corresponding to single key. Below is my request URL
https://api.openweathermap.org/data/2.5/onecall?lat=28.46&lon=77.03&exclude=hourly,alerts,minutely&appid=01s
Now in above URL there is exclude key in which multiple parameters are passing how to add these in my interface. Below is my interface.
ApiService.class
interface ApiService {
@GET("data/2.5/onecall")
fun getCurrenttemp(@Query("lat") lat:String,
@Query("lon") lon:String,
@Query("exclude") exclude:String,
@Query("appid") appid:String):Observable<Climate>
}
How can I make the desired request?
Upvotes: 0
Views: 1147
Reputation: 3193
As the exclude
parameter portion in the documentation of One Call API says,
By using this parameter you can exclude some parts of the weather data from the API response. It should be a comma-delimited list (without spaces).
So it's not asking for multiple values, it's rather one String value with comma-separated option tags with no spaces between them. Just put "hourly,alerts,minutely
" in a String variable & pass that string as you already have in the following line of code, @Query("exclude") exclude:String
, via your interface and it should work:
var excludeParamToPass = "hourly,alerts,minutely"
One example of API from that same reference:
https://api.openweathermap.org/data/2.5/onecall?lat=33.441792&lon=-94.037689&exclude=hourly,daily&appid={API key}
Upvotes: 1