SimpleApiClient icon indicating copy to clipboard operation
SimpleApiClient copied to clipboard

Multipart upload image along with other text fileds

Open nowfalsalahudeen opened this issue 6 years ago • 1 comments

sorry i unexpectedly closed that issue this is i got..

java.lang.IllegalArgumentException: @Part parameters can only be used with multipart encoding. (parameter #3) for method EkalawyaApi.updateProfile 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 $Proxy0.updateProfile(Unknown Source)

code i have used. @POST("/user/profile/update") fun updateProfile(@Header("Authorization") headerAuth: String, @Body @MultiPart(name = "image", mimeType = "image/*") file: Uri, @Part("name")name: RequestBody, @Part("email")email: RequestBody): Observable<String>

Api.create().updateProfile("UserToken", pickedImage, //Uri RequestBody.create(MediaType.parse("text/plain"), name.text.toString()), RequestBody.create(MediaType.parse("text/plain"), email.text.toString())).observe( onStart = {

            },
            onEnd = {

            },
            onError = {
                println(it.message)
            },
            onSuccess = {
                println(it)
            }
    )

nowfalsalahudeen avatar Feb 27 '18 06:02 nowfalsalahudeen

Try to annotate your method with @Multipart which is a retrofit annotation.

On Tue, 27 Feb 2018 at 2:01 PM, Nowfal [email protected] wrote:

sorry i unexpectedly closed that issue this is i got..

java.lang.IllegalArgumentException: @part https://github.com/part parameters can only be used with multipart encoding. (parameter #3 https://github.com/jaychang0917/SimpleApiClient/issues/3) for method EkalawyaApi.updateProfile 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 $Proxy0.updateProfile(Unknown Source)

code i have used. @post https://github.com/post("/user/profile/update") fun updateProfile(@Header https://github.com/header("Authorization") headerAuth: String, @Body https://github.com/body @multipart https://github.com/multipart(name = "image", mimeType = "image/*") file: Uri, @part https://github.com/part("name")name: RequestBody, @part https://github.com/part("email")email: RequestBody): Observable

Api.create().updateProfile("UserToken", pickedImage, //Uri RequestBody.create(MediaType.parse("text/plain"), name.text.toString()), RequestBody.create(MediaType.parse("text/plain"), email.text.toString())).observe( onStart = {

        },
        onEnd = {

        },
        onError = {
            println(it.message)
        },
        onSuccess = {
            println(it)
        }
)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jaychang0917/SimpleApiClient/issues/6, or mute the thread https://github.com/notifications/unsubscribe-auth/AFGYzxSVNMJ1vPT5d-grbniqOAxrp7qjks5tY5pXgaJpZM4SUZnF .

jaychang0917 avatar Feb 27 '18 11:02 jaychang0917