I already checked the other related question but none of what they suggested works for my case. I am working with Retrofit 2.2 and GSON to get the Rest response : this is what the response look like:
{"idUser":0,"nom":"kaddour","prenom":"hanedi","login":"hanedi@gmail.com","password":null,"genre":"f","adresse":"ettahrir","codePostal":8050,"tel":20333473,"active":0,"panneaux":null,"lesalertes":null,"paysuser":null,"ville":null}
Its a valid json format yet whenever I call using this code I get the Expected Begin_Object exception:
apiService = RestService.createService(SolarAPIService.class);
Call<User> call = apiService.authentif(email, pass);
call.enqueue(new Callback<User>() {
@Override
public void onResponse(Call<User> call, retrofit2.Response<User> response) {
user=response.body();}
I cant find where things went wrong. Any help appreciated ! Edit this is my User class :
public class User {
@SerializedName("idUser")
@Expose
private int idUser;
@SerializedName("nom")
@Expose
private String nom;
@SerializedName("prenom")
@Expose
private String prenom;
@SerializedName("login")
@Expose
private String login;
@SerializedName("password")
@Expose
private String password;
@SerializedName("genre")
@Expose
private String genre;
@SerializedName("adresse")
@Expose
private String adresse;
@SerializedName("codePostal")
@Expose
private int codePostal;
@SerializedName("tel")
@Expose
private int tel;
@SerializedName("active")
@Expose
private int active;
@SerializedName("panneaux")
@Expose
private List<PanneauV> panneaux;
@SerializedName("lesalertes")
@Expose
private List<Alerte> lesalertes;
@SerializedName("paysuser")
@Expose
private Pays paysuser;
@SerializedName("ville")
@Expose
private Ville ville;
//Constructor with arguments and Constructor without arguments
//getters and setters