通过改造2.0发送邮件请求以保持安静

时间:2016-05-19 10:54:40

标签: android rest retrofit2

我正在使用RESTful API的项目 我尝试使用retrofit 2.0向服务发送帖子请求,但我只收到错误500.

我不知道我的错误是什么。

这是我的主要活动:

Retrofit retrofit = new Retrofit.Builder().
            baseUrl(url).
            addConverterFactory(GsonConverterFactory.create()).
            build();

    final RestInterface restInterface = retrofit.create(RestInterface.class);
button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            LoginRequest loginRequest = new LoginRequest();
            loginRequest.setAction("loginvendor");
            loginRequest.setAppkey(PharmaApp.APPKEY);
            loginRequest.setFilters("title,entity_id,email");
            loginRequest.setUsername("pvakriraevil93@gmail.com");
            loginRequest.setPassword("12345612");
            final Call<UserSystem> usercall =  restInterface.getUser("loginvendor",PharmaApp.APPKEY,"pvakriraevil93@gmail.com","12345612","title,entity_id,email");
            Log.e("Data request",usercall+"");
            usercall.enqueue(new Callback<UserSystem>() {
                @Override
                public void onResponse(Call<UserSystem> call, Response<UserSystem> response) {
                    int statusCode = response.code();
                    Toast.makeText(TestActivity.this, ""+statusCode, Toast.LENGTH_SHORT).show();
                }

                @Override
                public void onFailure(Call<UserSystem> call, Throwable t) {
                    Log.d("onFailure", ""+ t.getMessage());
                    Toast.makeText(TestActivity.this, "onFailure__"+t.getMessage(), Toast.LENGTH_SHORT).show();

                }
            });
        }
    });

这是我的界面:

public interface RestInterface {

@POST("rest/mobileapi")
Call<UserSystem> getUser(@Field("action") String action,
                         @Field("appkey") String appkey,
                         @Field("username") String username,
                         @Field("password") String password,
                         @Field("filters") String filters);
}

这是我的UserSystem文件:

public class UserSystem {

@SerializedName("entity_id")
@Expose
private int entity_id;

@SerializedName("email")
@Expose
private String email;

@SerializedName("title")
@Expose
private String name;



public UserSystem(){

}

public int getId() {
    return entity_id;
}

public void setId(int id) {
    this.entity_id = id;
}

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

public String getEmail() {
    return email;
}

public void setEmail(String email) {
    this.email = email;
}
}

和我在webservice中的json文件

enter image description here

0 个答案:

没有答案