Skip to content
Advertisement

com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT at line 1 column 39 path $.message

i am making login function in android using retrofit. I have created an endpoint for login validation, then I have tested it using Postman using raw (json) and it worked. But when I enter the endpoint into android using retrofit I get an error message like this:

com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT at line 1 column 39 path $.message

can anyone help me?

So here my source:

ApiClient

JavaScript

AuthInterface

JavaScript

AuthPost

JavaScript

LoginActivity

JavaScript

Advertisement

Answer

Are you sure about:

JavaScript

Usually this error appears if this field is Object. Does your JSON looks like

JavaScript

or something like:

JavaScript

If it is the second variant so you should simple change the field to necessary type.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement