This is not duplicate question i have checked all but i m not getting data. Its execute everytime failure method and everytime i am getting error message.
I am using MVVM android architecture component + Retrofit structure.
response:
{
"statuscode": 0,
"statusmessage": "",
"data": {
"userdetails": {
"id": "3",
"name": "xxx",
"mobile": "123456789",
"username": "xxx",
"password": "xxx",
"createdate": "2019-08-14 16:51:22",
"updatedate": "2019-08-14 16:51:22",
"active": "Y",
"userdeviceid": 2
},
"contacttypes": [
{
"id": "1",
"name": "xxx",
"active": "Y"
},
{
"id": "5",
"name": "xxx",
"active": "Y"
},
{
"id": "2",
"name": "xxx",
"active": "Y"
},
{
"id": "4",
"name": "xxx",
"active": "Y"
},
{
"id": "3",
"name": "xxx",
"active": "Y"
}
]
}
}
Now these are my classes.
This is my APIResponse class.
public class APIResponse {
@SerializedName("statuscode")
private int statuscode;
@SerializedName("statusmessage")
private String statusmessage;
@SerializedName("data")
DATAModel dataModel;
public int getStatuscode() {
return statuscode;
}
public void setStatuscode(int statuscode) {
this.statuscode = statuscode;
}
public String getStatusmessage() {
return statusmessage;
}
public void setStatusmessage(String statusmessage) {
this.statusmessage = statusmessage;
}
public DATAModel getDataModel() {
return dataModel;
}
public void setDataModel(DATAModel dataModel) {
this.dataModel = dataModel;
}
}
This is my DATAModel class.
public class DATAModel {
@SerializedName("userdetails")
Userdetails userdetails;
@SerializedName("contacttypes")
List<ContactTypes> contactTypes;
public Userdetails getUserdetails() {
return userdetails;
}
public void setUserdetails(Userdetails userdetails) {
this.userdetails = userdetails;
}
public List<ContactTypes> getContactTypes() {
return contactTypes;
}
public void setContactTypes(List<ContactTypes> contactTypes) {
this.contactTypes = contactTypes;
}
}
This is my Userdetails class.
public class Userdetails implements Serializable {
@SerializedName("id")
private String userId;
@SerializedName("name")
private String name;
@SerializedName("mobile")
private String mobile;
@SerializedName("username")
private String username;
@SerializedName("password")
private String password;
@SerializedName("createdate")
private String createdate;
@SerializedName("updatedate")
private String updatedate;
@SerializedName("active")
private String active;
@SerializedName("userdeviceid")
private String userdeviceid;
public String getUserdeviceid() {
return userdeviceid;
}
public void setUserdeviceid(String userdeviceid) {
this.userdeviceid = userdeviceid;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getCreatedate() {
return createdate;
}
public void setCreatedate(String createdate) {
this.createdate = createdate;
}
public String getUpdatedate() {
return updatedate;
}
public void setUpdatedate(String updatedate) {
this.updatedate = updatedate;
}
public String getActive() {
return active;
}
public void setActive(String active) {
this.active = active;
}
}
ContactTypes
public class ContactTypes implements Serializable {
@SerializedName("id")
private String contactId;
@SerializedName("name")
private String name;
@SerializedName("active")
private String active;
public String getContactId() {
return contactId;
}
public void setContactId(String contactId) {
this.contactId = contactId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getActive() {
return active;
}
public void setActive(String active) {
this.active = active;
}
}
Though everytime I am getting failure. The message is Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 74 path $.data
Advanced help would be appreciated!