Reputation:
Hello I am trying to use @Query in retrofit but I am getting error something like this :-
must not have replace block. For dynamic query parameters use @Query.
here is my interface :-
public interface Parser {
@GET("weather?q={city}&appid=0a8")
Call<Model> getModel(@Query("city") String city);
}
And this is in my Activity :-
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("xyz/")
.addConverterFactory(GsonConverterFactory.create())
.build();
Parser parser = retrofit.create(Parser.class);
Call<Model> call = parser.getModel("london");
Thanks in advance
Upvotes: 1
Views: 117
Reputation: 199
if your api query should be like -
BASE_URL/weather?q=london&appid=0a8
Then use
@GET("weather")
Call<Model> getModel(@Query("q") String city,@Query("appid") String app_id);
Upvotes: 1
Reputation: 2430
In this case you should use @Path
instead of @Query
public interface Parser {
@GET("weather?q={city}&appid=0a8")
Call<Model> getModel(@Path("city") String city);
}
Upvotes: 0