I just make a GET request, but I get this error:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.yomac_000.chargingpoint/com.example.yomac_000.chargingpoint.AllStores}: java.lang.IllegalArgumentException: Unable to create converter for java.util.List<model.Store>
And this is because of this line of code:
Call<List<Store>> call = subpriseAPI.listStores(response);
So, I tried with this line of code to see what type it is:
System.out.println(subpriseAPI.listStores(response).getClass().toString());
But then I get the same error, so it does not let me know what type it is. Below you can see my code.
StoreService.java:
public class StoreService { public static final String BASE_URL = "http://getairport.com/subprise/"; Retrofit retrofit = new Retrofit.Builder() .baseUrl(BASE_URL) .build(); SubpriseAPI subpriseAPI = retrofit.create(SubpriseAPI.class); String response = ""; public List<Store> getSubprises() { Call<List<Store>> call = subpriseAPI.listStores(response); try { List<Store> listStores = call.execute().body(); System.out.println("liststore "+ listStores.iterator().next()); return listStores; } catch (IOException e) {
SubpriseAPI.java:
public interface SubpriseAPI { @GET("api/locations/get") Call<List<Store>> listStores(@Path("store") String store); }
Store.java:
public class Store { String name; }
I am using Retrofit version 2.0.0-beta2.
java android retrofit
superkytoz
source share