I am using okhttp Retrofit in my Android application to make network requests. For one of the requests, I get this error:
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: expected BEGIN_OBJECT, but there was STRING in row 1 column 1 path $
I see 201 response in the logs, but Retrofit throws this error. Below is my code.
signup(signupParams, new Callback<Member>() { @Override public void success(Member member, Response response) { if (member != null) { UserAccount userAccount = new UserAccount(member); userAccount.save(); } @Override public void failure(RetrofitError re) { BusProvider.post(new SignupFailedEvent(re, email)); } });
SignupParams value is
{"emailAddress":" test@gmail.com ","password":"tester123","userSource":"APH"}
I tested this json with jsonLint and it is valid json. And this is my member class, which should be the perfect answer.
public class Member { public String emailAddress; public String token; public long id; public String firstName; public String lastName; }
An example response should look something like this:
{ "emailAddress": " test@gmail.com ", "id": 1437811, "token": "sdhshdghsdhhsdbcjhbsjdhc", "firstName": "John", "lastName": "Smith" }
source share