简体   繁体   English

改造:@GET中的多个查询参数

[英]Retrofit: multiple query parameters in @GET

I have problem with multiple parameters in @GET. 我在@GET中有多个参数有问题。 If I have two, everything is working fine, but if I have three (i need three) it skipping onResponse method and onFailure is executed. 如果我有两个,一切工作正常,但是如果我有三个(我需要三个),它将跳过onResponse方法并执行onFailure。 Does anyone know why? 有人知道为什么吗?

This is interface 这是界面

@GET("CalendarJson")
Call<List<Raspored>> getKalendar(
        @Query("department") String department,
        @Query("semester") String semester,
        @Query("year") int year);

Retrofit retrofit = new Retrofit.Builder()
        .baseUrl(basicUrl)
        .addConverterFactory(GsonConverterFactory.create())
        .build();


KalendarService kalendarService = retrofit.create(KalendarService.class);

And this is where I call it 这就是我所说的

KalendarService.kalendarService.getKalendar(department,semester,year).enqueue(new Callback<List<Raspored>>() {
        @Override
        public void onResponse(Call<List<Raspored>> call, Response<List<Raspored>> response) {
            if(response.isSuccessful()){
                raspored = response.body();
                //TODO
            }
        }

        @Override
        public void onFailure(Call<List<Raspored>> call, Throwable t) {
            Toast.makeText(getApplicationContext(), "Failure", Toast.LENGTH_SHORT).show();
        }
    });

我认为这与您的第三个参数的数据类型有关

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM