요청 매개 변수가있는 URL이 { "EmailAddress": "[email protected]", "PassWord": "password"}와 같이 JsonFormat에 있습니다. 요청 된 매개 변수입니다. POSTMAN에서 사용할 때 okey.but 프로그램을 요청할 때 오류 응답이 나타납니다. 나는이 발췌문을 보시길. 안드로이드에서 Retrofit을 사용하는 방법 본문과 함께 POST 방법?
public class LoginModel {
@SerializedName("EmailAddress")
public String userName;
@SerializedName("PassWord")
public String userPass;
}
@Override
public String toString() {
Log.e("POSTLOGIN_MODEL" , userName+"||"+userPass);
return "{" +
"EmailAddress='" + userName + '\'' +
", PassWord='" + userPass + '\'' +
'}';
}
}
그 후 나는 인터페이스를 사용 하였다.
public interface ApiService {
@FormUrlEncoded
@POST("/json/syncreply/AuthenticateUserRequest?")
Call<LoginResponse> LoginService(@Field("EmailAddress") String userName, @Field("PassWord") String userPass, Callback<LoginResponse> callBack);
그 후 나는 활동을 통해 이러한 인터페이스 메소드를 호출하는데 사용. Advance.any 응답에서
감사를 피해주십시오 영어 appriciated.my 것입니다. 변환, 이제login.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if(input_username.getText().toString() != null && input_password.getText().toString() != null && !input_username.getText().toString().isEmpty() && !input_password.getText().toString().isEmpty()){ LoginModel loginCredentials = new LoginModel(); loginCredentials.userName = "[email protected]"; loginCredentials.userPass = "password"; String request = "{\"EmailAddress\":\"[email protected]\"," + "\"PassWord\":\"pass\"}"; sendPost(loginCredentials); }else{ Toast.makeText(getApplicationContext() , "Please enter valid Username and Password." , Toast.LENGTH_LONG).show(); } } }); public void sendPost(LoginModel name) { Log.e("TAG","||"+name.userPass+"||"+name.userName); // mAPIService.savePost(name).enqueue(new Callback<LoginModel>() { Call<LoginResponse> call = mAPIService.LoginService(name.userName, name.userPass, new Callback<LoginResponse>() { @Override public void onResponse(Call<LoginResponse> call, Response<LoginResponse> response) { Log.e("TAG" , "RESPONSE"+"||"+response.body()); } @Override public void onFailure(Call<LoginResponse> call, Throwable t) { Log.e("TAG" , "FAILURE"+"||"+t.getMessage()); } }); }
@FormUrlEncoded @POST(WEBSERVICE_NAME) Call<ModelClass> methodName( @Field("parameters" + "[]") ArrayList<String> paramsArrayList );
모델 클래스의 당신의 ArrayList를 : 당신의 나머지 클라이언트 인터페이스 측
검사를 통과하기 위해 http://stackoverflow.com/a/21423093/3442067 – uday
하시기 바랍니다 @uday 안녕하세요 당신은 내 프로그래밍 단계를 볼 수 있습니다 내가 무슨 짓을하고 어떤 일이 잘못되면 감사를 알리십시오. – RAJAN