我試圖讓在GET方法改造2.x的 使用參數的所有數據,但respon預計BEGIN_ARRAY但BEGIN_OBJECT在改造2java.lang.IllegalStateException:預期BEGIN_ARRAY但BEGIN_OBJECT在改造2
這是我的代碼訪問URL服務
public interface BukuResepMasakanAPI {
public static String baseURL = "http://10.108.233.76/buku_resep_masakan_service/";
//membuat Instance Retrofit
Retrofit client = new Retrofit.Builder()
.baseUrl(baseURL)
.addConverterFactory(GsonConverterFactory.create())
.build();
@POST("jenis_resep")
public Call<JenisResepModel> getJenisResep(@Body JenisResepModel model);
@GET("get_resep_by_jenis/{id_jenis_resep}")
public Call<List<DetailResepModel>> getDetailResep(@Path("id_jenis_resep") String id_jenis_resep);
}
,這是我的代碼來調用改造
public void loadData(){
BukuResepMasakanAPI apiService = BukuResepMasakanAPI.client.create(BukuResepMasakanAPI.class);
DetailResepModel model = new DetailResepModel();
Log.d("lappet",""+idJenisResep);
Call<List<DetailResepModel>> call = apiService.getDetailResep(idJenisResep);
//proses call
call.enqueue(new Callback<List<DetailResepModel>>() {
@Override
public void onResponse(Call<List<DetailResepModel>> call, Response<List<DetailResepModel>> response) {
List<DetailResepModel> resep = response.body();
Log.d("idjenisresep",""+idJenisResep+" size "+resep.size());
}
@Override
public void onFailure(Call<List<DetailResepModel>> call, Throwable t) {
Toast.makeText(getApplicationContext(),"Failed to connect",Toast.LENGTH_SHORT).show();
Log.d("failed", "" + t.toString());
}
});
}
我希望你能幫我解決這個問題
[改造的可能的複製 - java.lang.IllegalStateException:預期BEGIN \ _ARRAY但是BEGIN \ _OBJECT](http://stackoverflow.com/questions/34917713/retrofit-java-lang-illegalstateexception-expected-begin-array-but-was-begin-o) – Bharatesh