Hello, I have a rest webservice that takes a POST metod with multipart message:
@Path("transferFile") @POST @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces(MediaType.APPLICATION_XML) public String multipartTest(com.sun.jersey.multipart.MultiPart data) { try { // get first body part (index 0) BodyPart bp = multiPart.getBodyParts().get(0); etc.. Now I tried to write a client on android to send a file to this server. So I used the normal way to send multipart message on android: HttpClient client = new DefaultHttpClient(); client.getParams().setParameter("http.socket.timeout", new Integer(90000)); // 90 second HttpPost httpPost = new HttpPost("http://127.0.0.1:8080/webapp/ transferFile"); httpPost.setHeader("Content-Type", MediaType.MULTIPART_FORM_DATA ); //tried with and without base64 byte [] encodedWavestream = Base64.encodeBytesToBytes(wavestream); InputStream ins = new ByteArrayInputStream(encodedWavestream); InputStreamBody body = new InputStreamBody(ins, "test" ); int send = ins.available(); MultipartEntity requestContent = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE ); requestContent.addPart("stream", body); httpPost.setEntity(requestContent); HttpResponse Response = client.execute(httpPost); An this gives an annoying response from the server : HTTP Status 400 - Bad Request The request sent by the client was syntactically incorrect (Bad Request). I check the server log files but there is nothing there. So I don't know what's the origin of this error. I have wrote a simple html page with a post formula and 'multipart/form-data' content-type and it works. I created a Jersey client on a PC and it also works. However I have big problems with implementing this Jersey api on android. Why my android client does not work? Can anybody help please? -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en