Retrofit Post Parameter Retrofit Post Parameter java java

Retrofit Post Parameter


Try using this

public interface SafeUserApi { @FormUrlEncoded    @POST("/api/userlogin")    void getUserLogin(            @Field("client_id") String id,            @Field("client_secret") String secret,            @Field("username") String uname,            @Field("password") String password,            Callback<LoginResult> cb    );}

Here parm1 is the POST parameter that you will be passing it to the server.This will solve your problem

in case if you are using PHP u can access the param1 using $uname= $_POST('username');

EDIT 1:

retrofit 2.0 version:

public interface SafeUserApi {    @FormUrlEncoded    @POST("/api/userlogin")    Call<ResponseBody>  getUserLogin(            @Field("client_id") String id,            @Field("client_secret") String secret,            @Field("username") String uname,            @Field("password") String password    );}


You can also pass multiple field parameter:for example:

@FormUrlEncoded@POST("/oauth/access_token")void getToken(    @FieldMap Map<String, String> params,     Callback<FacebookLoginUserResponse> callback);


Retrofit 2.0 version:

@FormUrlEncoded@POST("api/v2/users/sign_in")Call<SignInResult> userSignIn(        @FieldMap HashMap<String, String> authData);