How to make HTTP GET request in URL that has params appended by &
using Retrofit in Android?
URL: http://api.com?name=remote&class=TV
Currently, i am using:
@GET("http://api.com?name={name}&class={class}")
Call<CustomType> get(
@Path(value = "name",encoded = false) String name,
@Path(value = "class",encoded = false) String class);
I am getting following error:
java.lang.IllegalArgumentException: URL query string "name={name}&class={class}"
must not have replace block.
For dynamic query parameters use @Query.
It's a standard GET request url. Just use @Query
:
@GET("http://api.com")
Call<CustomType> get(
@Query("name") String name,
@Query("class") String classs);
It will access url:
http://api.com?name=remote&class=TV
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With