如何在翻新中发送json格式参数的请求参数
Interface--
public interface ApiPhotoInterface {
@Headers("Content-Type: application/json")
@POST("photo/re/v7")
Call<PhotoModel> getResponse(@Body ParamModel paramModel);
}
//This is the Interface class
MainClass.java-- 在主要班级
ApiPhotoInterface apiInterface = ApiPhotoClient.getApi();
Call<ParamModel> call = apiInterface.getResponse();
如何在getResponse方法中设置参数?
这是客户端类,其中提到了基本URL和接口
public class ApiPhotoClient {
private static final String BASE_URL = " https://services.something.com/api/";
private static ApiPhotoInterface apiInterface;
public static ApiPhotoInterface getApi() {
if (apiInterface == null) {
apiInterface = new Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build()
.create(ApiPhotoInterface.class);
}
return apiInterface;
}
}
2 param models--
public class ParamModel {
@SerializedName("Key")
@Expose
private String apiKey;
@SerializedName("affId")
@Expose
private String affId;
@SerializedName("act")
@Expose
private String act;
@SerializedName("latitude")
@Expose
private String latitude;
@SerializedName("longitude")
@Expose
private String longitude;
@SerializedName("devinf")
@Expose
private String devinf;
@SerializedName("app")
@Expose
private String appver;
@SerializedName("Details")
@Expose
private List<ParamDetailModel> Details = null;
public String getApiKey() {
return apiKey;
}
public void setApiKey(String apiKey) {
this.apiKey = apiKey;
}
public String getAffId() {
return affId;
}
public void setAffId(String affId) {
this.affId = affId;
}
public String getAct() {
return act;
}
public void setAct(String act) {
this.act = act;
}
public String getLatitude() {
return latitude;
}
public void setLatitude(String latitude) {
this.latitude = latitude;
}
public String getLongitude() {
return longitude;
}
public void setLongitude(String longitude) {
this.longitude = longitude;
}
public String getDevinf() {
return devinf;
}
public void setDevinf(String devinf) {
this.devinf = devinf;
}
public String getAppver() {
return appver;
}
public void setAppver(String appver) {
this.appver = appver;
}
public List<ParamProductDetailModel> getProductDetails() {
return productDetails;
}
public void setProductDetails(List<ParamProductDetailModel> productDetails) {
this.productDetails = productDetails;
}
}
public class ParamProductDetailModel {
@SerializedName("productId")
@Expose
private String productId;
@SerializedName("qty")
@Expose
private String qty;
public String getProductId() {
return productId;
}
public void setProductId(String productId) {
this.productId = productId;
}
public String getQty() {
return qty;
}
public void setQty(String qty) {
this.qty = qty;
}
}
如何在.getResponse()中设置参数? 问题是如何在活动类的getResponse中发送请求参数。