android - @Part parameters can only be used with multipart encoding. (parameter #8) -


before post question here, have tried add @multipart above interface method , searching in stackoverflow still cannot find similar problem.

in case, try send image using typedfile server. interface method :

 @headers({"content-type: application/json"})     @post("/user/change")     void postchange(@query("name") string name, @query("email") string  email, @query("password") string password, @query("phone") string phone, @query("user_id") string userid, @query("address[]") string[] listaddress, @query("head[]") string[] head, @part("photo_profile") typedfile photoprofile, @body typedinput jsonobject, callback<receivedto> callback); 

edit

in method can see @part , @body. if add @multipart above method, throw error @body parameters cannot used form or multi-part encoding. (parameter #9)

i using retrofit 1.9

we use @query get request , in fact @query append parameter @ end of url, see doc examples.

if need send user profile info server, use multipart

multipart parts use 1 of retrofit's converters or can implement requestbody handle own serialization.

for example in following example send profile photo description server:

@multipart @put("user/photo") call<user> updateuser(@part("photo") requestbody photo, @part("description") requestbody description); 

you can add more additional attribute [additional @part]. see complete example here step step explain how this.

edit: jackwarthon explain here, @body annotation defines single request body.

interface foo {   @post("/jayson")   fooresponse postjson(@body foorequest body); } 

Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -