Table of Contents

Tasks Executed from Request Body

Products: FastReport Cloud, FastReport Corporate Server, FastReport Publisher

As mentioned in the previous section, Service solutions provides the ability to run tasks without prior saving. To do this, you should make a POST request to the path /api/tasks/v1/Tasks/run, passing all the necessary data in the request.

For example, to build a PDF document and send it via FTP, you need to pass data such as the template identifier (entityId) or the template itself (content) in the inputFile object, as well as data for connecting to the FTP server.

Let's look in detail at how to work with such tasks using the REST API.

About ViewModels and Types

When working, you will pass different ViewModels in JSON format. It is important that the first field of any ViewModel should be "$t": "Name". Detailed examples will be provided below in this article.

View Models for running Tasks On-the-Fly (without saving)

View Models for running transformer tasks on-the-fly:

  • RunPrepareTaskVM
  • RunExportTemplateTaskVM
  • RunExportReportTaskVM

View Models for running transport tasks on-the-fly:

  • RunEmailTaskVM
  • RunWebhookTaskVM
  • RunFTPUploadTaskVM
  • RunS3UploadTaskVM

View Models for running other tasks on-the-fly:

  • RunFetchTaskVM

Running a Task on-the-Fly (from request body)

To run a task on-the-fly, you should use the RunTask method.

Let's look at running a report export task followed by saving to S3 storage:

 curl --location 'https://{host_name}/api/tasks/v1/tasks/run' \
--header 'accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic {base64(apikey:api-key-value)}' \
--data '{
  "$t": "RunExportTemplateTaskVM",
  "subscriptionId": "{workspace id}",
  "inputFile": {
    "$t": "RunInputFileVM",
    "entityId": "{template id}",
    "type" : "Template",
    "fileName": "Template.frx"
  },
  "format": "Pdf",
  "transports": [
    {
    "$t": "RunS3UploadTaskVM",
    "accessKey": "{public_access_key}",
    "secretKey": "{secret_access_key}",
	"bucketName": "storage",
	"destinationFolder": "test",
	"useAws": true,
	"enableSsl": true,
	"region": "us-east-1"
    }
  ]
}'

In the EntityId field, you should enter real object identifiers. Otherwise, the task will be terminated with an error.

Also, instead of it, in the inputFile object you can pass the template content in the content field as a Base64 string.

A list of all available ViewModels is available at the link - https://{host_name}/api/swagger/index.html