I'd like to send a post request to server & I have multiple key-value params and a list of files like so:
@FormUrlEncoded
@POST("index.php")
Call<MyObjResponse> myCall(@Part List<MultipartBody.Part> files, @FieldMap Map<String, String> params);
I get a error:
java.lang.IllegalArgumentException: @Part parameters can only be used with multipart encoding. (parameter #1) for method IRestApi.pushLocalChangesWithMultipartCall at retrofit2.ServiceMethod$Builder.methodError(ServiceMethod.java:752) at retrofit2.ServiceMethod$Builder.methodError(ServiceMethod.java:743) at retrofit2.ServiceMethod$Builder.parameterError(ServiceMethod.java:761) at retrofit2.ServiceMethod$Builder.parseParameterAnnotation(ServiceMethod.java:592) at retrofit2.ServiceMethod$Builder.parseParameter(ServiceMethod.java:336) at retrofit2.ServiceMethod$Builder.build(ServiceMethod.java:204) at retrofit2.Retrofit.loadServiceMethod(Retrofit.java:170) at retrofit2.Retrofit$1.invoke(Retrofit.java:147) at java.lang.reflect.Proxy.invoke(Proxy.java:913) at $Proxy5.pushLocalChangesWithMultipartCall(Unknown Source)
I tryed to put @Multipart
in place of @FormUrlEncoded
and error become:
java.lang.IllegalArgumentException: @FieldMap parameters can only be used with form encoding. (parameter #2) for method IRestApi.pushLocalChangesWithMultipartCall at retrofit2.ServiceMethod$Builder.methodError(ServiceMethod.java:752) at retrofit2.ServiceMethod$Builder.methodError(ServiceMethod.java:743) at retrofit2.ServiceMethod$Builder.parameterError(ServiceMethod.java:761) at retrofit2.ServiceMethod$Builder.parseParameterAnnotation(ServiceMethod.java:567) at retrofit2.ServiceMethod$Builder.parseParameter(ServiceMethod.java:336) at retrofit2.ServiceMethod$Builder.build(ServiceMethod.java:204) at retrofit2.Retrofit.loadServiceMethod(Retrofit.java:170) at retrofit2.Retrofit$1.invoke(Retrofit.java:147) at java.lang.reflect.Proxy.invoke(Proxy.java:913) at $Proxy5.pushLocalChangesWithMultipartCall(Unknown Source)
p.s. POST
is a mult I can't use PUT