【发布时间】:2018-10-01 06:48:41
【问题描述】:
在我的项目中,我有两个模型。我想将客户的信息发送到服务器并从服务器获得响应。
在 android studio 中,我想通过改造将模型发送到服务器。当我发送请求时,改造返回一个空响应给我。谁能帮帮我?
这是我的 customers_role 模型:
public class customers_role {
@SerializedName("customers_models")
private customers_model customers_models;
@SerializedName("mobile")
private String mobile;
@SerializedName("phone")
private String phone;
@SerializedName("first_job")
private String first_job;
@SerializedName("second_job")
private String second_job;
@SerializedName("first_address")
private String first_address;
@SerializedName("second_address")
private String second_address;
@SerializedName("postal_code")
private String postal_code;
@SerializedName("nik_name")
private String nik_name;
@SerializedName("description")
private String description;
@SerializedName("created_at")
private String created_at;
@SerializedName("updated_at")
private String updated_at;
@SerializedName("status")
private boolean status;
public customers_role() {
}
}
这里是customers_model:
public class customers_model {
@SerializedName("id")
private Integer id;
@SerializedName("name")
private String name;
@SerializedName("family")
private String family;
@SerializedName("code")
private String code;
@SerializedName("father")
private String father;
@SerializedName("birthday")
private String birthday;
@SerializedName("created_at")
private String created_at;
@SerializedName("updated_at")
private String updated_at;
@SerializedName("status")
private boolean status;
public customers_model() {
}
public customers_model(String name, String family, String code, String father, String birthday) {
this.name = name;
this.family = family;
this.code = code;
this.father = father;
this.birthday = birthday;
}
}
我的界面是:
@Headers("Accept: application/json")
@POST("customers")
Call<customers_role> send_info(@Header("Authorization") String token, @Body customers_role info);
谢谢
`
【问题讨论】:
-
服务器的响应是什么?首先在邮递员中检查
-
你能分享一下json响应吗?
-
@JeelVankhede 我用邮递员对其进行了测试,效果很好,但在 android studio 中我的回复为空
-
@BayarŞahintekin 这是邮递员 [ "فیلد customer.name الزامی است", "فیلد customer.family الزامی است", "فیلد customer.code الزامی است", "فیلد customer.father 的回复", "فیلد customer.birthday الزامی است" ]
-
@zahras 看起来你在邮递员中得到字符串 json 数组,你期待你的模型在改造中做出回应,这就是为什么它是
null。