How to send a PDF to JasperSoft Server?

Is there a way to send a PDF back to the Server created with a template that comes from a JasperSoft Server? I have a Template on my JasperServer running on Docker. I can display and create my desired PDF on my App and the Template works. Now I want to save that Report that I create back to the server to a special Folder. Is it possible to tell Jasper to save the Report on for Example Report Execution? Maybe with some params or something? 

 

The Code - creating the PDF from Template: 

    await fetch(
 
      "http://docker03.xxx.lan/jasperserver/rest_v2/reportExecutions",
 
      {
 
        method: "POST",
 
        headers: {
 
          Accept: "application/xml",
 
          "Content-Type": "application/xml",
 
        },
 
 
 
        body: `  
 
          <reportExecutionRequest>
 
            <reportUnitUri>/xxx/xxx</reportUnitUri>
 
            <async>false</async>
 
            <freshData>true</freshData>
 
            <saveDataSnapshot>false</saveDataSnapshot>
 
            <outputFormat>html</outputFormat>
 
            <interactive>false</interactive>
 
              <parameters>

Report Execution:

    await fetch(
 
      `http://docker03.xxx.xxx/jasperserver/rest_v2/reportExecutions/${this.state.requestID}/exports/${this.state.exportID}/outputResource`,
 
      {
 
        method: "GET",
 
      }
 
    )

So either in one of those 2 calls OR something I also found but I cant get to work:

      fetch(
 
      "http://docker03.xxx.xxx/jasperserver/rest_v2/resources/Name_Folder",
 
      {
 
        method: "POST",
 
        headers: {
 
          'Content-Type': 'application/pdf'
 
        },
 
        body: MyPDFfromFolderStructure
 
  })

When I try this by taking a PDF right from my Folder Structure I get ERROR: Network request failed

Also in generall: Are there any tutorials or "good" Docs for this? All I can see is some basics but no real examples on how to do it via REST. Also the tutorials I've seen from Jasper are bad and cover basics mostly for JasperStudio only.

abusch100's picture
Joined: Apr 11 2022 - 2:31am
Last seen: 3 weeks 3 days ago

1 Answer:

You can use the "jobs service" to trigger an immediate execution of the report and send the pdf to the server at a specific location.

https://community.jaspersoft.com/documentation/tibco-jasperreports-serve...

You may also upload the file to the location using the resource service.

https://community.jaspersoft.com/documentation/tibco-jasperreports-serve...

sanderse's picture
3177
Joined: Jul 31 2017 - 3:51pm
Last seen: 3 days 3 hours ago
Feedback