The problem is this. I am sending a music file. I keep getting error 422
. For this reason, it seems I am not able to properly position my body
this is my output from the console
Content-Disposition: form-data; name="Content-Disposition: form-data;
name="audio[file]"; filename="tr.mp3""
Content-Transfer-Encoding: binary
Content-Type: audio/mpeg
Content-Length: 6028060
and my code
@Multipart
@Headers({"Content-Type: multipart/form-data;", "Accept:application/json, text/plain, */*"})
@POST("audios")
Call<SoundResponse> saveSound(@Part ("Content-Disposition: form-data; name=\"audio[file]\"; filename=\"tr.mp3\"") RequestBody file,
@Query("auth_token") String authToken);
and called this method
RequestBody body = RequestBody.create(MediaType.parse("audio/mpeg"), file);
GeoService.saveSound(body,SoundResponseCallback, getAuthToken());
I also found this stuff
Send file to server via retrofit2 as object
It seems to me that the problem is that the field looks like this "audio [file]"
Thank you for your help