android–@part在multipart中以双引号发送字符串参数

android–@part在multipart中以双引号发送字符串参数,第1张

概述遵循API,我呼吁编辑用户配置文件.我必须发送用户个人资料图片,所以我在API中使用了multipart.@Multipart@POST(ApiURLs.EDIT_USER_PROFILE)Call<EditProfileModel>EditUserProfile(@Part("user_id)StringuserId,@Part("user_name")StringuserName,@Part("language_i

遵循API,我呼吁编辑用户配置文件.我必须发送用户个人资料图片,所以我在API中使用了multipart.

@Multipart@POST(APIURLs.EDIT_USER_PROfile)Call<EditProfileModel> EditUserProfile (@Part("user_ID) String userID , @Part("user_name") String username ,@Part("language_ID") String languageID , @Part("state_ID") String stateID , @Part Multipartbody.Part profilePicture); 

当Service调用所请求的参数时会是这样的

“user_ID”:“”23“”
“user_name”:“”Keval Shukla“”
“language_ID”:“”27“”
“state_ID”:“53”“

如何使用MultiPart删除该双引号

解决方法:

它必须像 –

@Multipart@POST(APIURLs.EDIT_USER_PROfile)Call<EditProfileModel> EditUserProfile (                              @Part("user_ID") Requestbody userID ,                               @Part("user_name") Requestbody username ,                              @Part("language_ID") Requestbody languageID ,                               @Part("state_ID") Requestbody stateID ,                               @Part Requestbody profilePicture); 

并且,要创建requestbody,

file file = new file(imageURI.getPath());Requestbody fbody = Requestbody.create(MediaType.parse("image/*"), file); // file requestbodyRequestbody username = Requestbody.create(MediaType.parse("text/plain"), usernameSTRING); // String requestbody
总结

以上是内存溢出为你收集整理的android – @part在multipart中以双引号发送字符串参数全部内容,希望文章能够帮你解决android – @part在multipart中以双引号发送字符串参数所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/web/1108815.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存