Retrofit is throwing the above error. I have tried some of the solutions i saw here but none is working. Here is my code
public void getMaterials()
{
RestAdapter adapter = new RestAdapter.Builder().setEndpoint(Root_Url).build();
materialAPI api = adapter.create(materialAPI.class);
api.getMaterials(String.valueOf(categoryId), new Callback <List<materialClass>>() {
@Override
public void success(List<materialClass> list, Response response) {
materials = list;
showList();
customAdapter customAdapter = new customAdapter();
listView.setAdapter(customAdapter);
}
@Override
public void failure(RetrofitError error) {
Log.i(TAG, "Error here"+error.toString());
}
});
}
public class materialClass{
private String courseTitle;
private String courseAuthor;
private String fileName;
private String fileSize;
private String description;
private long Id;
public String getMaterialName(){return courseTitle;}
public String getAuthorName(){return courseAuthor;}
public String getFileName(){return fileName;}
public String getFileSize(){return fileSize;}
public String getFileDescription(){return description;}
public long getId(){return Id;}
public void setMaterialName(String resourceName){this.courseTitle =resourceName;}
public void setAuthorName(String authorName){this.courseAuthor = authorName;}
public void setFileName(String fileName){this.fileName = fileName;}
public void setFileSize(String fileSize){this.fileSize = fileSize;}
public void setFileDescription(String fileDescription){this.description = fileDescription;}
public void setFileContent(byte[] resourceFile){this.resourceFile = resourceFile;}
public void setId(long Id){this.Id = Id;}
}
public interface materialAPI {
@GET("/Course/{Id}")
public void getMaterials(@Path("Id") String Id, Callback<List<materialClass>> response);
}
I have included all the code i'm implementimg. Below is an low the json response is supposed to look it. This is a test data by the way.
{
"Id": 1,
"courseTitle": "Testing",
"courseAuthor": "Just Testing",
"dateCreated": "2018-12-07T00:00:00",
"description": "Just to see if it's working",
"categoryName": "programming",
"fileName": "Android_Programming_Succinctly.pdf",
"fileSize": "3038893"
}
The Json is not in an array format and i guess that;s why retrofit is throwing the error.How to i pass this data to retrofit