users@jersey.java.net

"Missing start boundary" when calling for Jersey client API

From: Giuseppe Catanese <gcatanese_at_yahoo.com>
Date: Thu, 4 Feb 2010 05:53:14 -0800 (PST)

Hi all this is similar to an old thread ("form multipart post "Missing start boundary" exception") https://jersey.dev.java.net/servlets/ReadMsg?list=users&msgNo=7186 however I have a slightly different issue. If I use an html form to submit the file it works fine (the service receives the file and stores it on the file system), but if I use the client API I instead get javax.ws.rs.WebApplicationException: org.jvnet.mimepull.MIMEParsingException: Missing start boundary I am running my web app on Tomcat 5.5.28, here is my source: Resource implementation: @Path("upload") @POST @Produces("text/plain") @Consumes(MediaType.MULTIPART_FORM_DATA) public String uploadFile( @FormDataParam("documentId") Long documentId, @FormDataParam("file") FormDataContentDisposition formDataContentDisposition, @FormDataParam("file") InputStream content) { logger.debug("documentId: " + documentId); logger.debug("content: " + content); logger.debug("formDataContentDisposition.getFileName: " + formDataContentDisposition.getFileName()); // here save the file return "ok"; } Client implementation: public String uploadFile(Long documentId, InputStream inputStream) { logger.debug("documentId: " + documentId); logger.debug("inputStream: " + inputStream); WebResource webResource = client.resource("http://localhost:8081/dccm/rest/document/upload"); Form form = new Form(); form.add("documentId", documentId); form.add("file", inputStream); String response = (String) webResource .type(MediaType.MULTIPART_FORM_DATA) .accept(MediaType.TEXT_PLAIN) .post(String.class, form); logger.debug("Web Service response: " + response); return response; } Any idea? Do I miss something that the html page instead does? Any help is really appreciated Tnx in advance Beppe