The obvious reason for this would be not providing proper content type. But I am providing. Still i am getting Unsupported Media Type. Not sure why. Any help greatly appreciated.
Client c = Client.create();
WebResource resource = c.resource(HOST+"/test");
Gson gson = new Gson();
Test test = new Test();
test.setTestName("TEST AUTOMATION");
resource.header("Content-Type", "Application/json");
String testStr = gson.toJson(test);
System.out.println("Request Str: "+testStr);
ClientResponse response = resource.post(ClientResponse.class, testStr);
System.out.println("POST response : "+response);
POST response : POST http://host:8888/test returned a response status of 415 Unsupported `enter code here`Media Type
This is how i solved it. Its really weird. Until i combine the statements as below, it didn't work. From the above program that i wrote, combine the header statement and post statement as below. Also don't forget to put charset=UTF-8.