Ad

How To Set Parameter In Interface In Retrofit Request

There is an interface for retrofit:

public interface GetDataService {
    @GET("/news")
    Call<ItemAPI> getAllItems();
}

How I can give parameters when I do the request? For example,

/news?id=1001

I think it must be looking like:

@GET("/news?id={id}")

But how do I do it correctly?

Ad

Answer

@GET("/v1/news_content")
Call<ItemPageAPI> getAllItems(@Query("id") String id);

@Query can add your parameters to the URL by itself.

Ad
source: stackoverflow.com
Ad