をGET:レトロフィット - 峠のURL値を動的に - 私は、例えばURLを持っている方法
ここhttps://vpic.nhtsa.dot.gov/api/vehicles/DecodeVinValues/KMHDC8AEXAU084769?format=JSON
私は動的に
Retrofit2でそれを行う方法をKMHDC8AEXAU084769?format=JSON
この部分を変更したいです。
私は次のように試してみました:唯一のPOSTのためではないGETのためにサポートしている
@FormUrlEncoded
@GET("{input}")
Call<Result> getVin(@Path("input") String input, @Field("format") String format);
しかし@FormUrlEncoded
。
これは私がそれを呼び出しています方法です:
ApiInterface apiService = ApiClient.getClient().create(ApiInterface.class);
Call<Result> call = apiService.getVin(vin, "JSON");
call.enqueue(new Callback<Result>() {
@Override
public void onResponse(Call<Result> call, Response<Result> response) {
Result result = response.body();
Log.e("Result: ", "" + response.body());
Gson gson = new Gson();
String json = gson.toJson(result);
responseTV.setText("" + json);
}
@Override
public void onFailure(Call<Result> call, Throwable t) {
// Log error here since request failed
Log.e("MainActivity", t.toString());
Toast.makeText(MainActivity.this, "Try later", Toast.LENGTH_SHORT).show();
}
});
しようとしたが、それはあなたがGETアノテーションにURL構造を適応させる必要があります。もちろん、 –
を働いていないしてくれてありがとうあなたの目的のために –