【问题标题】:Error End of input at line 1 column 1 path $ Retrofit错误在第 1 行第 1 列的输入结束路径 $ 改造
【发布时间】:2018-10-27 02:02:15
【问题描述】:

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

这是我的界面

 @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");

请帮帮我 提前致谢

【问题讨论】:

  • 你解决了吗?

标签: android retrofit


【解决方案1】:

在我的情况下,这只发生在模拟器上(在某些情况下并非一直如此)。出于某种原因,有时发生了一些事情,服务器为我提供的响应没有最后一个字符,例如“}”,这导致了错误。不知道是改装还是其他原因造成的。无法在真实设备上重现它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-09-15
    • 2021-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-04
    • 2021-12-30
    • 2016-08-21
    相关资源
    最近更新 更多