@Test
public void testAuthenticationForSubmitModelingRequest() {
String url = "http://localhost:9081/prop/submitModellingRequest";
String name = "admin";
String password = "admin";
String authString = name + ":" + password;
byte[] authStringEnc = Base64.getEncoder().encode(authString.getBytes());
String input = "{\"modelingVersionID\":\"1007\",\n" +
"\"modelingRequestID\":\"75891\",\n" +
"\"cycleId\":\"20033\",\n" +
" \"imtId\":\"225\",\n" +
" \"submarketID\":\"0\",\n" +
"\"brandSubSubGroupID\":\"11\",\n" +
"\"modelStatus\":null,\n" +
"\"modelingTechStatus\":null,\n" +
"\"requestType\":null,\n" +
"\"targetType\":\"0\",\n" +
"\"targetTypeName\":null,\n" +
"\"serverId\":\"1\"}";
String authStringEnc1 = new String(authStringEnc);
System.out.println("Base64 encoded auth string: " + authStringEnc);
Client restClient = Client.create();
WebResource webResource = restClient.resource(url);
ClientResponse resp = webResource.accept("application/json").header("Authorization", "Basic " + authStringEnc1)
.post(ClientResponse.class,input);
if (resp.getStatus() != 201) {
System.err.println("Unable to connect to the server");
}
String output = resp.getEntity(String.class);
System.out.println("response: " + output);
}
Ошибка 415 при попытке запустить модульный тест, даже если передать json в правильном формате. Попытка вызова метода post на моем остальных API, пожалуйста, помогите