我知道有很多关于此问题的线索,我确实通过了它们并查看了相同的Retrofit POST示例,但我不确定我在这做错了什么, lemme知道是否有任何
@Multipart
@POST("api/customerdetail")
Call<Array> addUser(@Part("CustomerName") String CustomerName, @Part("CustomerId") String CustomerId, @Part("UserId") String UserId, @Part("VehicleCompanyName") String VehicleCompanyName, @Part("VehicleModelType")String VehicleModelType, @Part("VehicleNumber")String VehicleNumber, @Part("Location")String Location);
//用于调用的方法
private void simpleMethod() {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://endpoint.net/")
.addConverterFactory(GsonConverterFactory.create())
.build();
GetDataService service = retrofit.create(GetDataService.class);
Call<Array> arrayListCall = service.addUser("Peter Jenkins", UUID.randomUUID().toString(),"user2","AUDI","R3","BVZ-009","-55,-93.23"); arrayListCall.enqueue(new Callback<Array>() {
@Override
public void onResponse(Call<Array> call, Response<Array> response) {
Log.e("RESPONSE",response.toString());
}
@Override
public void onFailure(Call<Array> call, Throwable t) {
Log.e("ERROR",t.toString());
} }); }
像邮递员中的魅力一样,上传图像是没有必要的,至少从api端
任何意见都将深受赞赏