Answer the question
In order to leave comments, you need to log in
Retrofit 2. Why is there an error returning the query result?
Guys, I have not been able to fix the error for many days, so I decided to write to the forum in the hope of helping, because. always visible from the outside.
I use Retrofit 2 to work with a bank service to get currency data. I describe an interface where there are 2 methods: one without parameters (data for the current day) and one with a parameter (data for any date).
public interface ApiService {
@GET("statdirectory/exchange?date=20170916&json")
Call<List<MyModel>> getСurrency();
@GET("statdirectory/exchange{date}&json")
Call<List<MyModel>> getСurrency(@Path("date") String inputDate);
}
ApiService apiService = RetrofitController.getApi();
// Здесь вызываю метод без параметров и результат возвращается без ошибок, т.е. УСПЕШНО!
apiService.getCurrency().enqueue(new Callback<List<MyModel>>() {
@Override
public void onResponse(Call<List<MyModel>> call, Response<List<MyModel>> response) {
if (response.isSuccessful()) {
Toast.makeText(MainActivity.this, "УСПЕШНО", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(MainActivity.this, "ОШИБКА", Toast.LENGTH_SHORT).show();
}
}
....
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question