I know there must've been 1000 posts like this one, but I searched for the mistake everywhere and could not find it, so i hope you guys can take a look and tell me if you notice something i am missing.
Token class
public class Token {
public static final String POST = "tokens";
@SerializedName("token")
@Expose
private String token;
@SerializedName("role")
@Expose
private String role;
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
}
Entity class
public class Entity {
public Entity(){}
private Token mToken;
@SerializedName("email")
@Expose
private String mEmail;
@SerializedName("password")
@Expose
private String mPassword;
public Entity setFirstName(String firstName){return this;}
public Entity setLastName(String lastName){return this;}
public Entity setEmail(String email){
mEmail = email;
return this;
}
public Entity setPassword(String password){
mPassword = password;
return this;
}
public Entity setPasswordConfirmation(String passwordConfirmation){return this;}
public Entity setAddress(String address){return this;}
public Entity setCity(String city){return this;}
public Entity setCountryId(Integer countryId){return this;}
public Entity setToken(Token token){
mToken = token;
return this;
}
public String getEmail(){ return mEmail; }
public String getPassword(){ return mPassword; }
public Token getToken(Token token){ return mToken; }
}
APIService
@POST(Token.POST)
Observable<Token> loginEntity(@Body Entity entity);
API call
Observable<Token> loginEntityCall = RestClient.getInstance().service.loginEntity(loginEntity);
What OkHttp outputs
--> POST http://randomapi/api/v1/tokens http/1.1
Content-Type: application/json; charset=UTF-8
Content-Length: 55
{"email":"sample.user@example.com","password":"123456"}
--> END POST (55-byte body)
It returns
<-- 500 Internal Server Error
Here is the copied value into postman
So postman gives OK, and my app gives me 500. I checked all values and i cannot find the mistake. :p