这是我要添加的网址:
/ survey / add?moderator_id = 1&password = 123456&visitor_name = nabil&visitor_mobile = 123456&entity_id = 32&visitor_gender = male&survey = {“意见”:“重大事件”,“答案”:[{“答案”:1,“ question_id”:9} ,{“ answer”:1,“ question_id”:10},{“ answer”:1,“ question_id”:11}]}
我想将最后一个参数添加到我的帖子请求中,该怎么做!
这是发帖请求:
public interface Serviecs {
@POST("survey/{add}")
@FormUrlEncoded
Call<SubmitSurvey> getSubmit(@Path("add") String add,
@Field("moderator_id") int moderator_id,
@Field("visitor_name") String visitor_name,
@Field("visitor_mobile") String visitor_mobile,
@Field("entity_id") int entity_id,
@Field("visitor_gender") String visitor_gender
);
}
答案 0 :(得分:0)
Call<SubmitSurvey> getSubmit(@Path("add") String add,
@Field("moderator_id") int moderator_id,
@Field("visitor_name") String visitor_name,
@Field("visitor_mobile") String visitor_mobile,
@Field("entity_id") int entity_id,
@Query ReqAnsQues visitor_gender
);
ReqAnsQues的结构
Class ReqAnsQues{
@SerializedName("answer")
String answer;
@SerializedName("visitor_gender")
String visitorGender;
}
@Field需要必填参数。如果@Field是可选的,我们可以改用@Query并传递一个空值