I a very new in retrofit.I want to fetch some data from server.but I am unable to do this. Please help me.when I call api then show me an error "expected begin array but was begin object".
private void getCatagories(){
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(Api.BASE_URL)
.addConverterFactory(GsonConverterFactory.create()) //Here we are using the GsonConverterFactory to directly convert json data to object
.build();
Api api = retrofit.create(Api.class);
Call<List<Catagoty>> call = api.getCatagories();
Log.e("this",Api.BASE_URL+"");
call.enqueue(new Callback<List<Catagoty>>() {
@Override
public void onResponse(Call<List<Catagoty>> call, Response<List<Catagoty>> response) {
List<Catagoty> catagotiesList = response.body();
//Creating an String array for the ListView
String[] heroes = new String[catagotiesList.size()];
//looping through all the heroes and inserting the names inside the string array
for (int i = 0; i < catagotiesList.size(); i++) {
heroes[i] = catagotiesList.get(i).getSubCatagoryDescription();
}
//displaying the string array into listview
listView.setAdapter(new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1, heroes));
}
@Override
public void onFailure(Call<List<Catagoty>> call, Throwable t) {
Toast.makeText(getApplicationContext(), t.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}