Jersey Client 2.6 PUT请求

时间:2014-03-05 16:22:58

标签: java jersey-2.0 jersey-client

我目前正面临一些泽西2客户问题。

以下curl cmd正在运行:

curl --user user:pwd -H "Content-Type: /xml" -T data.xml -X PUT http://www.example.com/folder/file

现在我想对Jersey API做同样的事情。但是下面的代码产生了400响应:

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));

这个请求有什么问题吗?

0 个答案:

没有答案