httpclient - MultipartEntity Android always return server error -
i have 2 days facing problem sending multipart form request include data , images, , server give me error "unsupported media type"
i have tried 3 version of apache httpclient (4.1, 4.3, 4.5)
here code
multipartentitybuilder multipartentity = multipartentitybuilder.create(); multipartentity.addtextbody("categoryid", string.valueof(categoryid), contenttype.text_plain); multipartentity.addbinarybody("primaryimage", primaryimage, contenttype.create("image/jpeg") , "test.jpg");
i have added following headers
request.setheader("accept", "application/json"); request.setheader("content-disposition","form-data"); request.setheader("content-type","multipart/form-data"); request.setheader("enctype", "multipart/form-data");
i using post request digest authentication
when print content of multipart form request found following data
--2gj-9i6ivydt_6we0ck0dtkuv_hwuu-6m7 content-disposition: form-data; name="categoryid" content-type: text/plain; charset=iso-8859-1 content-transfer-encoding: 8bit 1 --2gj-9i6ivydt_6we0ck0dtkuv_hwuu-6m7 content-disposition: form-data; name="primaryimage"; filename="test.jpg" content-type: image/jpeg content-transfer-encoding: binary ����-�exif
the server keep sending me error , server admin told me server can't parse form-data , format of request wrong
can please
edit 1
when remove headers request , remove image server able read text parameter.
when remove headers request , keep sending image got sockettimeoutexception.
i don't know problem
Comments
Post a Comment