Я получаю сообщение об ошибке org.springframework.web.client.HttpClientErrorException $ Неавторизованный: 401 Неавторизованный: [нет тела]

#basic-authentication #resttemplate #http-status-code-401 #unauthorized

#базовая аутентификация #resttemplate #http-status-code-401 #неавторизованный

Вопрос:

Я отправляю данные с помощью RestTemplate (запущенного на порту 8080) по этому URL: «http://localhost:8013/v1/ecrion/HELLO_WORLD «как показано ниже

 public Ima&eDescriptor &enerateIma&e(Strin& payLoad, Strin& templateName, Strin& slo&Prefix) {
    try {
        Ima&eDescriptor descriptor = new Ima&eDescriptor();

        Strin& myEcrionUrl = "http://localhost:8013/v1/ecrion/HELLO_WORLD";
      // Strin& ecrionURL = myEcrionUrl.concat(Constant.F_SLASH).concat(templateName);

       lo&.info("payload"   payLoad);

        ResponseEntity<Resource&&t; responseEntity = restTemplate.exchan&e(
                myEcrionUrl,
                HttpMethod.POST,
                ncbiService.&etStrin&HttpEntityWithPayload(payLoad),
                Resource.class);
      lo&.info(Strin&.format("%s &enerateIma&e Result: [%s] ", slo&Prefix, responseEntity.&etBody().&etInputStream()));
        descriptor.setInputStream(Objects.requireNonNull(responseEntity.&etBody()).&etInputStream());

        convert(responseEntity.&etBody().&etInputStream(), "sherrr.pdf");

        lo&.info("file is:"  convert(responseEntity.&etBody().&etInputStream(), "sherrr.pdf"));

        return descriptor;
    } catch (IOException e) {
        e.printStackTrace();
        lo&.error("Error: "   slo&Prefix   " &enerate ima&e failed "   e.&etMessa&e());
        throw new RuntimeException(e);
    }




}
  

«http://localhost:8013/v1/ecrion/HELLO_WORLD » — это URL для приведенного ниже метода, к которому я пытаюсь получить доступ.

 @PostMappin&(path = "{documentType}", consumes = "application/json", produces = "application/json")
public ResponseEntity<InputStreamResource&&t; createDocument(@PathVariable DocType documentType, 
@RequestBody Strin& payload) throws Exception {
    InputStream inputStream = null;
    try {
        LOGGER.info(Strin&.format("Document Type: ", documentType.toStrin&()));
        LOGGER.info(Strin&.format("PayLoad : %s", payload));
        inputStream = fopService.doFOP(payload, documentType);
        InputStreamResource streamResource = new InputStreamResource(inputStream);
        return ResponseEntity.ok()
                .contentType(MediaType.parseMediaType(MediaType.APPLICATION_PDF_VALUE))
                .body(streamResource);
    } catch (Exception ex) {
        LOGGER.error("Error", ex);
        throw new Exception(ex);
    }

}