简体   繁体   English

在改造中使用@Multipart也包括@FormUrlEncoded

[英]Using @Multipart in retrofit to include @FormUrlEncoded as well

@Multipart
@FormUrlEncoded
@POST(Endpoints.KID_PROFILE_BASE + "/{uuid}" + Endpoints.POST_KID_PROFILE_END)
void postKidProfilePhoto(@Path(value = "uuid", encode = false) String startuuid, @Part("post[body]") TypedString requestJson, Callback<KidProfile> callback);

I have the code above. 我上面有代码。 This POST should format a dynamic url (which works with the FormUrlEncoded), and then fill the Body parameter with a TypedString of Json data. POST应该格式化动态网址(与FormUrlEncoded一起使用),然后用Json数据的TypedString填充Body参数。

However when I make the request to the url, retrofit throws the error: 但是,当我向url发出请求时, retrofit会引发错误:

Only one encoding annotation is allowed.

Which means I have to give up either @Multipart or @FormUrlEncoded . 这意味着我必须放弃@Multipart@FormUrlEncoded Is there a way to keep both of them in order to not throw away dynamically generating my url? 有没有办法让它们都保留,以免丢掉动态生成我的网址? Or a work around? 还是可以解决?

I know I can remove @FormUrlEncoded and somehow include it as a @Part in my postKidProfilePhoto but I am not sure the procedure to do that and cannot find any documentation showing that being done. 我知道我可以删除@FormUrlEncoded并以某种方式将其作为@Part在我的postKidProfilePhoto但是我不确定执行此操作的过程,并且找不到任何显示完成的文档。

你不能使用@FormUrlEncoded@Multipart ,因为他们说在这里 ,它的工作原理没有它?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM