F
F
FBR2017-09-17 13:37:02
Java
FBR, 2017-09-17 13:37:02

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);
}

...and call the methods one by one.
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();
                }
            }
....

When I call the method with the getCurrency("20170916") parameter , an ERROR occurs!
The question is why? I sin on the query string, but, as for me, it's okay, because in theory, the string "statdirectory/exchange{date}&json" will turn into the form "statdirectory/exchange?date=20170916&json" .
Please tell me what could be the problem. Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
mr_serg77, 2017-09-17
@mr_serg77

Show the link in full, where the answer should come from, the full code, and what the error is.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question