错误第1行第1行路径$ Retrofit的输入结束

时间:2016-12-28 11:44:44

标签: android retrofit

我想在服务器和音频文件上传数据,但我在过去两天收到同样的错误

这是我的界面

 @Multipart
    @POST("index.php")
  Call<Result> uploadFile(@Part("client_phone") String phn,
                          @Part("call_type") String Ststus,
                          @Part("start_time") String Stime,
                          @Part("end_time")  String Etime,
                          @Part MultipartBody.Part body,
                          @Part("employe_phone") String emphn);

这是我的改造类

private static final String ROOT_URL ="http://192.168.0.113/recorder/api/";


public RetroClient() {

}

/**
 * Get Retro Client
 *
 * @return JSON Object
 */



private static Retrofit getRetroClient() {
    Gson gson = new GsonBuilder().setLenient().create();

    return new Retrofit.Builder()
            .baseUrl(ROOT_URL)
            .addConverterFactory(GsonConverterFactory.create(gson))
            .build();


}

public static ApiService getApiService() {
    return getRetroClient().create(ApiService.class);
}

这是对API的调用

RequestBody requestFile = RequestBody.create(MediaType.parse("multipart/form-data"), file);

    // MultipartBody.Part is used to send also the actual file name
    MultipartBody.Part body =
        MultipartBody.Part.createFormData("uploaded_file", file.getName(), requestFile);

    Misscall ms=new Misscall("7276367824","IN","2016-12-12_12:12:12","2016-12-12_12:13:03","7276367824");
    Gson gson=new Gson();
    String json=gson.toJson(ms);
    Log.i(MyApp.TAG, "Object Json"+ms);

  //Call<Result> resultCall = service.uploadFile(map,body);
  Call<Result> resultCall = service.uploadFile("7276367824","IN","123456","1234567",body,"7276367824");

请帮帮我 提前致谢

1 个答案:

答案 0 :(得分:0)

就我而言,这仅在模拟器上发生(并非在某些情况下一直如此)。由于某些原因,有时会发生一些事情,并且服务器提供给我的响应没有最后一个字符,例如“}”,这导致了错误。我不知道这是否是由于改造或其他原因引起的。无法在真实设备上复制。