我有问题,发送multipartRequest服务器。
I have problem with sending multipartRequest to server.
RequestBody file = RequestBody.create(MediaType.parse("application/json"), myFile);
return apiService.updateProfile2(token, file);
@Multipart
@POST("/profile/update")
Call<RegistrationResponse> updateProfile2(@Header(value = "X-AUTH-TOKEN") String toke, @Part(value = "json") RequestBody json);
问题:
请求体是空的,当它来到的服务器
request body is empty, when it come to server
首先,请您尝试发送mediaType的应用程序/ JSON为@Multpart,如果你想发送multpartfile所以你需要改变出头的你code。
First all, do you are trying send the mediaType "application/json" as @Multpart, if you want send the multpartfile so do you needs change somethings in your code.
事情是这样的:
@Multipart
@POST("/profile/update")
Call<RegistrationResponse> updateProfile2(
@Header(value = "X-AUTH-TOKEN") String toke,
@Part("myfile\"; filename=\"image.png\" ") RequestBody file);
和改变调用方法如下:
RequestBody file = RequestBody.create(MediaType.parse("multipart/form-data"), myFile);
return apiService.updateProfile2(token, file);
上一篇:进或Android的向后兼容性?兼容性、Android
下一篇:SCAN_RESULTS_AVAILABLE_ACTION返回的Android 6.0空单Andr、SCAN_RESULTS_AVAILABLE_ACTION、oid