users@jersey.java.net

[Jersey] Jersey Client 2.6 PUT request

From: Delm Schmidt <delm_at_gmx.net>
Date: Wed, 5 Mar 2014 18:26:21 +0100
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?