I am using postman extension for post request. I want to make same request with android. I used retrofit library for access my goal. But I can\'t get successful result. Where is
Which version you use in retrofit? Below code for version 2.0. If any Header require please check. If you can share url and username or password. I will check.
public interface Interfacem {
@FormUrlEncoded
@POST("login")
Call 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 result =service.getResponse("myUsername","myPassword");
result.enqueue(new Callback() {
@Override
public void onResponse(Response response) {
try {
System.out.println(response.body().string().toString());
} catch (IOException|NullPointerException e) {
e.printStackTrace();
}
}
@Override
public void onFailure(Throwable t) {
t.printStackTrace();
}
});