make pojo class like this way..
public class Details{
@SerializedName("address")
private String address;
@SerializedName("birthdate")
private String birthdate;
@SerializedName("profile_file_id")
private Object profileFileId;
@SerializedName("user_id")
private String userId;
@SerializedName("name")
private String name;
@SerializedName("email")
private String email;
public void setAddress(String address){
this.address = address;
}
public String getAddress(){
return address;
}
public void setBirthdate(String birthdate){
this.birthdate = birthdate;
}
public String getBirthdate(){
return birthdate;
}
public void setProfileFileId(Object profileFileId){
this.profileFileId = profileFileId;
}
public Object getProfileFileId(){
return profileFileId;
}
public void setUserId(String userId){
this.userId = userId;
}
public String getUserId(){
return userId;
}
public void setName(String name){
this.name = name;
}
public String getName(){
return name;
}
public void setEmail(String email){
this.email = email;
}
public String getEmail(){
return email;
}
}
ResponseData..
public class ResponseData extends ErrorResponse{
@SerializedName("response")
private String response;
@SerializedName("details")
private String details;
public void setResponse(String response){
this.response = response;
}
public String getResponse(){
return response;
}
public void setDetails(String details){
this.details = details;
}
public String getDetails(){
return details;
}
}
Error Response..
public class ErrorResponse {
@SerializedName("response")
private String response;
@SerializedName("details")
private String details;
}
make api call into interface..
@GET("path")
Call<ResponseData> getUserData();
api called.
Call<ResponseData> dataCall=apiInterface.getUserData();
dataCall.enqueue(new Callback<ResponseData>() {
@Override
public void onResponse(Call<ResponseData> call, Response<ResponseData> response) {
if (response!=null && response.isSuccessful() && response.body()!=null){
}
else{
if (response.errorBody()!=null){
ErrorResponse errorResponse=new Gson().fromJson(response.errorBody().toString(),ErrorResponse.class);
Log.d("Error data",response.errorBody().toString());
}
}
}
@Override
public void onFailure(Call<ResponseData> call, Throwable t) {
}
});