android - Retrofit parameters go empty to server -


i using retrofit library post request. i'm getting empty field area error server. parameters("signin[password] , signin[username]") go empty server. mistake ? thank you

retrofit retrofit = new retrofit.builder()                         .baseurl("http://myurl.com/")                         .addconverterfactory(gsonconverterfactory.create())                         .build();                 interfacem service = retrofit.create(interfacem.class);                 signbody body=new signbody("username","pass");                  call<responsebody> result =service.getresponse(body);                   result.enqueue(new callback<responsebody>() {                     @override                     public void onresponse(response<responsebody> response) {                         try {                              system.out.println(response.body().string().tostring());                             system.out.println(response.errorbody().string().tostring());                           } catch (ioexception|nullpointerexception e) {                             e.printstacktrace();                         }                      }                      @override                     public void onfailure(throwable t) {                         t.printstacktrace();                     }                 }); 

signbody class below:

public class signbody {      @serializedname("signin[username]") @expose private string username;     @serializedname("signin[password]") @expose private string password;      public signbody(string username, string password) {         this.username = username;         this.password = password;     }  }  

finally interfacem.class :

public interface interfacem {     @post("/login")     call<responsebody> getresponse(@body signbody body);  } 

there not problem when tried postman same think. postman screenshot

which version use in retrofit? below code version 2.0. if header require please check. if can share url , username or password. check.

public interface interfacem {      @formurlencoded     @post("login")     call<responsebody> getresponse(@field("username") string username,@field("password")string password ); }   retrofit retrofit = new retrofit.builder()                         .baseurl("http://myurl.com/")                         .build();                  interfacem service = retrofit.create(interfacem.class);                 call<responsebody> result =service.getresponse("myusername","mypassword");                 result.enqueue(new callback<responsebody>() {                     @override                     public void onresponse(response<responsebody> response) {                         try {                             system.out.println(response.body().string().tostring());                         } catch (ioexception|nullpointerexception e) {                             e.printstacktrace();                         }                      }                      @override                     public void onfailure(throwable t) {                         t.printstacktrace();                     }                 }); 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -