'Creating PDF in SpringBoot and Angular giving error 404 not found

I tried to create pdf file from backend through angular and spring boot but it giving me error 404. I think the url is correct. I tried to do the same way in other backend service it work just fine but in this service it giving 404. Do you know why ?

code in angular


  exportLoanAccountListPdf(state: any): Observable<Blob> {
    const lang = this.translateService.currentLang;
   
    return this.downloadService.downloadFile(`${this.baseUrl}/loans/listing/export/pdf?lang=${lang}&state=${state.toString()}`)
  }

code in springboot controller

@Permittable(value = AcceptedTokenType.TENANT, groupId = PermittableGroupIds.REPORT_MANAGEMENT)
  @GetMapping(
      value = "/loans/listing/export/pdf",
      consumes = MediaType.ALL_VALUE,
      produces = MediaType.APPLICATION_JSON_VALUE
  )
  @ResponseBody
  public ResponseEntity<byte[]> exportLoanAgreementListingPdf(
      @RequestParam(value = "lang", defaultValue = "en") final String lang,
      @RequestParam(value = "state") final String state) {

    final String chequeFilename = "loan-account-list"+".pdf";
    final String headerKey = "Content-Disposition";
    final String headerValue = String.format("attachment; filename=\"%s\"", chequeFilename);
    final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();

    final ArrayList<QueryParameter<?>> queryParameters = new ArrayList<>();
    queryParameters.add(new QueryParameter<>(RestUtils.PRODUCT_STATE, state));

    try {
      RestUtils.getReportModel(reportModelFactoryBean)
          .exportLoanAgreementListPdf(queryParameters, lang, byteArrayOutputStream);
      return ResponseEntity.ok()
          .contentType(MediaType.APPLICATION_PDF)
          .contentLength(byteArrayOutputStream.size())
          .header(headerKey, headerValue)
          .body(byteArrayOutputStream.toByteArray());
    } catch (final ServiceException ex) {
      throw ex;
    } catch (final Exception ex) {
      log.error(RestUtils.ERROR_WHILE_RUNNING_REPORT, ex);
      throw ServiceException.internalError(RestUtils.ERROR_WHILE_RUNNING_REPORT_0_1,
          ex.getClass().getSimpleName(), ex.getMessage());
    }
  }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source