Good morning everyone.
I am faced with the following situation:
I am performing a login using Retrofit for the requests, these return the user's data when successfully logged in through a json.
I am doing the validation through php, the problem arises when instead of json I return an error message, for example when the username or password are incorrect, retrofit returns these errors to me as
com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path $
since the error messages are of the type, "Wrong password" , "User not registered"
The question is: how can I receive these login errors without retrofit taking them as json malformation errors?
I remain attentive, in advance thank you very much
The problem is that retrofit understands that everything it receives will always be a json. To solve the problem I recommend that you put the error messages inside a json as well.
for instance: