Answer the question
In order to leave comments, you need to log in
Retrofit 2. How to set value for Boolean parameters?
There is a simple service:
public interface CatalogService
{
@GET("catalog")
Observable<PaginationData<CatalogItem>> paginate(
@Query("category") int category,
@Query("favorite") boolean favorite,
@Query("page") int page
);
}
http://example.com/api/v1/catalog?category=1&favorite=true&page=2
isFavorite() ? 1 : 0
? Answer the question
In order to leave comments, you need to log in
I'm sorry, but what's the beauty? a number in the url, it is logical that the service will also have a number, this will avoid confusion
If you have a model that has a boolean favor property, add a method to the model
int getFavor(){
return favor ?1:0;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question