Android 如何使用仅针对登录用户的改装来调用此api

Android 如何使用仅针对登录用户的改装来调用此api,android,retrofit2,Android,Retrofit2,我无法在登录活动中从接口类访问登录方法 这是我的api>http://localhost/AdminaService/AdminaService.svc/Verify_User_And_Password_For_login/{PUSER_ID}/{PPASSWORD}/{PUSER_SESSION_ID}/{PIPADDRESS}/{PAPPLICATION_ID} Api接口 public interface Api { @FormUrlEncoded @POST("Veri

我无法在登录活动中从接口类访问登录方法

这是我的api>
http://localhost/AdminaService/AdminaService.svc/Verify_User_And_Password_For_login/{PUSER_ID}/{PPASSWORD}/{PUSER_SESSION_ID}/{PIPADDRESS}/{PAPPLICATION_ID}

Api接口

public interface Api {

    @FormUrlEncoded
    @POST("Verify_User_And_Password_For_login")
    Call<LoginResponse>login(
            @Path("PUSER_ID") String user_id,
             @Path("PPASSWORD") String Ppassword
    );



}
公共接口Api{
@FormUrlEncoded
@POST(“验证用户和登录密码”)
呼叫登录(
@路径(“PUSER_ID”)字符串用户ID,
@路径(“PPASSWORD”)字符串PPASSWORD
);
}
“登录活动”

公共类LoginActivity扩展了AppCompatActivity{
私人编辑文本编辑用户,编辑通行证;
私人按钮btn_登录;
私有静态最终字符串Base_url=”http://localhost/AdminaService/AdminaService.svc/";
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity\u登录);
getSupportActionBar().hide();
如果(!isConnected(LoginActivity.this))构建对话框(LoginActivity.this.show();
edit_user=findviewbyd(R.id.editText_用户名);
edit_pass=findviewbyd(R.id.editText_密码);
btn_login=findViewById(R.id.button_sign);
字符串U_id=edit_user.getText().toString().trim();
String pass=edit_pass.getText().toString().trim();
btn_login.setOnClickListener(新视图.OnClickListener(){
@凌驾
公共void onClick(视图v){
改装改装=新改装.Builder()
.baseUrl(基本url)
.addConverterFactory(GsonConverterFactory.create())
.build();
Api=改装.create(Api.class);
Call=Call客户端
.getInstance()
.getApi()
.登录(用户id、Ppassword);
call.enqueue(新回调(){
@凌驾
公共void onResponse(调用、响应){
//登录后
}
@凌驾
失败时公共无效(调用调用,可丢弃的t){
}
});
}
});
}
@凌驾
public void onStart(){
super.onStart();
}
@凌驾
公共void onStop(){
super.onStop();
}
@凌驾
恢复时公开作废(){
super.onResume();
}
@凌驾
公共无效暂停(){
super.onPause();
}
}
@FormUrlEncoded
@POST(“验证用户和登录密码”)
呼叫登录(
@路径(“PUSER_ID”)字符串用户ID,
@路径(“PPASSWORD”)字符串PPASSWORD
);
您不能将登录参数作为pathparams传递,请改用@Field或@Query

@FormUrlEncoded
@POST("Verify_User_And_Password_For_login")
Call<LoginResponse>login(
        @Field("PUSER_ID") String user_id,
         @Field("PPASSWORD") String Ppassword
);
@FormUrlEncoded
@POST(“验证用户和登录密码”)
呼叫登录(
@字段(“PUSER_ID”)字符串用户ID,
@字段(“PPASSWORD”)字符串PPASSWORD
);

请参阅:

您知道
localhost
的意思吗?请指定服务器运行所在机器的IP地址,而不是localhost请不要使用明文密码:(我投票以打字错误结束这个问题。你的变量是
U\U id
pass
,而不是
User\U id
Ppassword
给出完整的登录url进行测试。
@FormUrlEncoded
@POST("Verify_User_And_Password_For_login")
Call<LoginResponse>login(
        @Path("PUSER_ID") String user_id,
         @Path("PPASSWORD") String Ppassword
);
@FormUrlEncoded
@POST("Verify_User_And_Password_For_login")
Call<LoginResponse>login(
        @Field("PUSER_ID") String user_id,
         @Field("PPASSWORD") String Ppassword
);