I have a rest post call. whenever I try to hit using postman it is working fine. but If I try same post call using JerseyAPI Client. I'm getting 400 Bad request
String URI = "rest uri";
Client client = Client.create();
WebResource webResource = client.resource(URI);
try {
String input1 = "{\"callType\": \"UPDATE\",\"emails\": [\"[email protected]\",\"[email protected]\"],\"event\": \"UPDATE_EVENT\",\"externalIds\": [ \"id\" ], \"fraudAction\": \"CONFIRMED_FRAUD\",\"fraudCategory\": \"Account Takeover\",\"memo\": \"test fraud case management for AD\",\"origin\": \"SE4\",\"phones\": [],\"requester\": \"corsairUser\",\"source\": \"LIVE\" }";
ClientResponse response = webResource.type("application/json")
.header("Authorization", "Basic secretKey")
.post(ClientResponse.class, input1);
if (response.getStatus() != 201) {
throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
}
System.out.println("Output from Server .... \n");
String output = response.getEntity(String.class);
System.out.println(output);
} catch (
Exception e) {
e.printStackTrace();
}
}
If I run same request in Postman using a above input, I'm able to hit api successfully and get 200, but getting 400 in JerseyAPI