0

i am trying to upload audio file to server with retrofit2. after sending request the response is : "message": "(1007) Unsupported audio format"

these are information that i'm sent with PostMan :

enter image description here

enter image description here

here my code :

InterFace :

 @Multipart
    @POST("audiofile")
    Call<ResponseModel> upload(@Header("X-SessionID") String account , @Part MultipartBody.Part file , @Query("path") String address);

and

 RequestBody requestFile = RequestBody.create(MediaType.parse("audio/*"), file);
        // MultipartBody.Part is used to send also the actual file name
        MultipartBody.Part body =
                MultipartBody.Part.createFormData("voice", file.getName(), requestFile);
        String descriptionString = "hello, this is description speaking";
        RequestBody description =
                RequestBody.create(
                        okhttp3.MultipartBody.FORM, descriptionString);

        Call<ResponseModel> response = requestInterface.upload(session , body , file.getName());
        response.enqueue(new Callback<ResponseModel>() {
            @Override
            public void onResponse(@NonNull Call<ResponseModel> call, @NonNull Response<ResponseModel> response) {

                Log.d("server-", "onResponse: " + new Gson().toJson(response.body()));
            }
            @Override
            public void onFailure(@NonNull Call<ResponseModel> call, @NonNull Throwable t) {
                Log.d("server-", "onResponse: " + t);
            }
        });
The MJ
  • 453
  • 7
  • 17

0 Answers0