0

I'm trying to do a POST call by adding "Content-Encoding" Header to the request. Here is my code

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 Response as follows : STATUS : 400 Response message : Request for service PreferencesLifecycle version 1.0- 211.0-35789706 is missing Content-Encoding header

Response says "Content-Encoding" header is missing. Can anyone help me here, and point me to the right way of doing it?

Nilamber Singh
  • 804
  • 1
  • 14
  • 33

1 Answers1

1
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();
Nilamber Singh
  • 804
  • 1
  • 14
  • 33