-1

My code

public interface ApiInterface 

{

    @GET("convert?q=USD_{currency}&compact=ultra&apiKey="+API_KEY)
    Call<Currency> getRates(@Path("currency") String currency );
}

But I am getting the following Error:

java.lang.IllegalArgumentException: URL query string "q=USD_{currency}&compact=ultra&apiKey=9b1166408fb8799dee9e" must not have replace block. For dynamic query parameters use @Query.

Bhoomika Patel
  • 1,895
  • 1
  • 13
  • 30
corgiwooer
  • 29
  • 5

2 Answers2

1

make your interface like this:

@GET("convert")
Call<Currency> getRates(@Query("q") String query, @Query("compact") String compact, @Query("apiKey") String apiKey);

You can call it like this way:

String mCurrency="$";

Call<Currency> call = mApiInterface.getRates("USD_"+mCurrency, "ultra", API_KEY);
Bhoomika Patel
  • 1,895
  • 1
  • 13
  • 30
0

You need to put your query parameters inside of the interface like this:

@GET("convert")
Call<Currency> getRates(@Query("q") String currency, @Query("compact") String compact, @Query("apiKey") String apiKey);
Androidz
  • 401
  • 1
  • 6
  • 19