users@jersey.java.net

[Jersey] Re: SEVERE : getting Bad Request (HTTP 400) error. Only for Jersey Server

From: sohit224 <sohit224_at_gmail.com>
Date: Sun, 13 Feb 2011 23:00:59 -0800 (PST)

Here is the client code as well :

1) Using jersey client
ClientConfig config = new DefaultClientConfig();
Client client = Client.create(config);
FormDataMultiPart fdmp = new FormDataMultiPart();
FormDataBodyPart fdp = new FileDataBodyPart("file",
filename,MediaType.MULTIPART_FORM_DATA_TYPE);
fdmp.bodyPart(fdp);

WebResource service = client.resource(UriBuilder.fromUri(baseUrl).build())
                                .path("macd").path("uploadFileRequest")
                                .type("multipart/form-data"")
                                .post(ClientResponse.class, fdmp);
response.getEntity(String.class);


2) Using HTML form.

<form action="url call"
enctype="multipart/form-data" method="post">
<p>
Please specify a file, or a set of files:<br>
<input type="file" name="xmlFile"/>
</p>
<div>
<input type="submit" value="Send">
</div>
</form>

-- 
View this message in context: http://jersey.576304.n2.nabble.com/SEVERE-getting-Bad-Request-HTTP-400-error-Only-for-Jersey-Server-tp6022640p6022705.html
Sent from the Jersey mailing list archive at Nabble.com.