添加 "Content-Encoding" header 到请求后 400 错误
400 error after adding "Content-Encoding" header to request
我正在尝试通过向请求添加 "Content-Encoding" Header 来执行 POST 调用。这是我的代码
Invocation.Builder builder =
webTarget.request(MediaType.APPLICATION_XML).header("Content-Encoding",
"xml").accept(MediaType.TEXT_PLAIN);
String xmlRequest=
buildMerchantPreferencesRequest(accountNumber,emailID,thresholdValue);
response = header.post(Entity.xml(xmlRequest.toString()));
String value = response.readEntity(String.class);
Thread.sleep(5000);
System.out.println("Service STATUS : "+response.getStatus());
System.out.println("Response message : "+value);
Returns 响应如下:
状态:400
响应消息:请求服务 PreferencesLifecycle 版本 1.0-
211.0-35789706 缺失 Content-Encoding header
响应显示 "Content-Encoding" header 丢失。
任何人都可以在这里帮助我,并指出正确的方法吗?
Response response;
String xmlRequest= buildMerchantNBPreferencesRequest(accountNumber,emailID,thresholdValue);
Variant variant = new Variant(MediaType.APPLICATION_XML_TYPE, null, null, "XML");
Invocation.Builder builder = merchantPreferencesClient.request().header("Content-Encoding", "XML").property("Content-Encoding", "XML");
Invocation invocation = builder.header("Content-Encoding", "XML").buildPost(Entity.entity(xmlRequest, variant));
response = invocation.invoke();
我正在尝试通过向请求添加 "Content-Encoding" Header 来执行 POST 调用。这是我的代码
Invocation.Builder builder =
webTarget.request(MediaType.APPLICATION_XML).header("Content-Encoding",
"xml").accept(MediaType.TEXT_PLAIN);
String xmlRequest=
buildMerchantPreferencesRequest(accountNumber,emailID,thresholdValue);
response = header.post(Entity.xml(xmlRequest.toString()));
String value = response.readEntity(String.class);
Thread.sleep(5000);
System.out.println("Service STATUS : "+response.getStatus());
System.out.println("Response message : "+value);
Returns 响应如下: 状态:400 响应消息:请求服务 PreferencesLifecycle 版本 1.0- 211.0-35789706 缺失 Content-Encoding header
响应显示 "Content-Encoding" header 丢失。 任何人都可以在这里帮助我,并指出正确的方法吗?
Response response;
String xmlRequest= buildMerchantNBPreferencesRequest(accountNumber,emailID,thresholdValue);
Variant variant = new Variant(MediaType.APPLICATION_XML_TYPE, null, null, "XML");
Invocation.Builder builder = merchantPreferencesClient.request().header("Content-Encoding", "XML").property("Content-Encoding", "XML");
Invocation invocation = builder.header("Content-Encoding", "XML").buildPost(Entity.entity(xmlRequest, variant));
response = invocation.invoke();