android - Retrofit 2.3 error Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $ -


here scenario...

i getting response postman below

    {     "success": 1,     "username": "anuj@cmail.com",     "password": "123456",     "userid": "1121",     "pass": "123456",     "email": "anuj@cmail.com",     "mobile": "902430000",     "name": "anuj" } 

and my pojo class below ( having constructor , getter setters)

    public class loginpojo {     @serializedname("success")     @expose     private int success;     @serializedname("username")     @expose     private string username;     @serializedname("password")     @expose     private string password;     @serializedname("userid")     @expose     private string userid;     @serializedname("pass")     @expose     private string pass;     @serializedname("email")     @expose     private string email;     @serializedname("mobile")     @expose     private string mobile;     @serializedname("name")     @expose     private string name; } 

creating rest adapter like

gson gson = new gsonbuilder()             .setlenient()             .create();     retrofit retrofit = new retrofit.builder()             .baseurl("http://theuroguard.in/")             .addconverterfactory(gsonconverterfactory.create(gson))             .build();      serverapi=retrofit.create(serverapi.class); 

**and interface **

 public interface serverapi {     @formurlencoded        @post("/mobile/user_login")         call<loginpojo> user_login(                @field("username") string username,                @field("password") string password,                @field("token") string token         );     } 

and calling below..

 serverapi.user_login(smail,spassword,token).enqueue(new callback<loginpojo>() {                 @override                 public void onresponse(call<loginpojo> call, response<loginpojo> response) {                      toast.maketext(mainactivity.this, ""+response.message().tostring(), toast.length_short).show();                     log.e("login error",response.message().tostring());                     dismiss_dialogue();                 }                  @override                 public void onfailure(call<loginpojo> call, throwable t) {                      dismiss_dialogue();                     log.e("login error",t.getmessage().tostring());                     toast.maketext(mainactivity.this, ""+t.getmessage().tostring(), toast.length_short).show();                 }             });     } 

i don't understand why getting suck error: java.lang.illegalstateexception: expected begin_object string @ line 1 column 1 path $

were need change, please assist


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -