I woudlike to send files using rest API :
String setTransferFile = "localhost:8080/api/transferFile";
public void callTransferFile(String nameFile) throws Exception {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
nameFile = "readme.txt";
HttpEntity<String> entity = new HttpEntity<>(nameFile, headers);
ResponseEntity<String> result = null;
try {
result = restTemplate.exchange(setTransferFile , HttpMethod.POST, entity, String.class);
logger.info("upload done");
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
assert result != null;
if (result.getStatusCode() != HttpStatus.OK) throw new Exception("upload impossible") ;
}
But I have always the error… when I try it directly with Swagger UI it works :
500 Internal Server Error: ({"timestamp":"2021-01-12T00:44:33.553+00:00","message":"No such file","details":"uri=/api/transferFile"})