users@jersey.java.net

[Jersey] Re: Jersey Client 2.6 PUT request

From: Craig McClanahan <craigmcc_at_gmail.com>
Date: Wed, 5 Mar 2014 13:03:22 -0800

I don't know if this is your whole problem, but "/xml" is not a valid MIME
type. It should be "application/xml" instead.



On Wed, Mar 5, 2014 at 9:26 AM, Delm Schmidt <delm_at_gmx.net> wrote:

> I'm currently struggling with some Jersey 2 Client problems.
>
> The following curl cmd is working:
> curl --user user:pwd -H "Content-Type: /xml" -T data.xml -X PUT
> http://www.example.com/folder/file
>
> Now I want to do the same with the Jersey API. But the following code
> produces a 400 response:
>
> Client client = ClientBuilder.newClient();
> HttpAuthenticationFeature authFeature =
> HttpAuthenticationFeature.universal("user","pwd");
> client.register(authFeature);
> WebTarget target = client.target("http://www.example.com/folder/file");
> InputStream stream = new
> ByteArrayInputStream(xmlString.getBytes(StandardCharsets.UTF_8));
> Response response = target.request().header("Content-Type:", "/xml")
> .put(Entity.entity(stream,
> MediaType.APPLICATION_OCTET_STREAM));
>
> Any idea whats wrong with this request?
>