when I am trying to upload an image using the multipart form with this code I am not getting the path of the file which I want to upload to the server.
@Headers({"Content-Type: application/json;charset=UTF-8"})
@Multipart
@POST("api/updateprofile")
Call<ResponseBody> uploadPhoto1(
@Header("Authorization") String token,
@Part("v_name") RequestBody name,
@Part MultipartBody.Part image,
RequestBody namePart = RequestBody.create(MediaType.parse("text/plain"), "Narendra");
File file = new File(filePath);
RequestBody filePart = RequestBody.create(MediaType.parse("image/*"), file);
MultipartBody.Part file1 = MultipartBody.Part.createFormData("v_image", file.getName(), filePart);
APIService apiService = ApiClient.getRetrofit().create(APIService.class);
Call<ResponseBody> Call = apiService.uploadPhoto1(token,namePart,file1);
How can I solve it?
I have Solve This Issue by my self
Just remove the header part from this interface
@Multipart
@POST("api/updateprofile")
Call<ResponseBody> uploadPhoto1(
@Header("Authorization") String token,
@Part("v_name") RequestBody name,
@Part MultipartBody.Part image,
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.