android - Retrofit post request with parameters -


i using postman extension post request. want make same request android. used retrofit library access goal. can't successful result. mistake in code ?

postman : enter image description here

my interface :

public interface interfacem {      @formurlencoded     @post("/login")     call<responsebody> getresponse(@field("signin[username]") string username,@field("signin[password]")string password ); } 

and retrofit usage :

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();                     }                 }); 

try provide body

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

change interface to

@post("/login")     call<responsebody> getresponse(@body signbody body); 

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 -