I don't understand all thing I have set in String. but still got this problem. when I test my web API got no issue on this thing.. but when I implement got this problem..
here my error
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2 path
here is my code to call get Section
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long itemID) {
if (position >= 0 && position < goodModelArrayList.size()) {
String section= goodModelArrayList.get(position).getSection();
//getSelectedCategoryData(section);
restService.getService().getSection(section, new Callback<VW_AC_Line_>() {
@Override
public void success(VW_AC_Line_ student, Response response) {
Toast.makeText(Viewattendance.this, "success", Toast.LENGTH_LONG).show();
}
@Override
public void failure(RetrofitError error) {
Toast.makeText(Viewattendance.this, error.getMessage().toString(), Toast.LENGTH_LONG).show();
}
});
} else {
Toast.makeText(Viewattendance.this, "Selected Category Does not Exist!", Toast.LENGTH_SHORT).show();
}
}
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
});
}
here my data class to call
public class VW_AC_Line_ {
public int ID;
public String Section;
public int getID(){
return ID;
}
public void setID(int id){
this.ID = id;
}
public String getSection() {
return Section;
}
public void setSection(String section) {
this.Section = section;
}
}
here is my calling method web api
@GET("/api/VW_AC_LINE_/deparment/{section}")
public void getSection(@Path("section") String section, Callback<VW_AC_Line_> callback);
here is web api calling
[{"ID":2665,"Section":"IT"}].
i think you are getting below response(array of objects) but expecting object.
array of objects: [{VW_AC_Line_:{ "a":2,"b":3}}]
Expected: {VW_AC_Line_:{ "a":2,"b":3}}