Preparing a report
This article describes how to build a report from a template using the FastReport Corporate Server report processor.
Getting started
You will need the following tools and features:
Knowledge on how to use API key in FastReport Corporate Server.
This article does not include the information about authentication and authorization.
The curl tool.
Any other REST client will work, however, the examples are provided for curl.
A report template.
You can learn how to upload a report template from the article Upload a new template.
Active subscription for FastReport Corporate Server.
Internet access.
Instructions
To build a template, you need a template identifier. To get the root directory, make a
GET
request tohttps://fastreport.cloud/api/rp/v1/Templates/Root
.A sample request.
curl -X GET "https://fastreport.cloud/api/rp/v1/Templates/Root" -H "accept: text/plain"
A sample response.
{ "name": "RootFolder", "parentId": null, "tags": [], "icon": "", "type": "Folder", "size": 16384, "subscriptionId": "5fa919fa292a8300019349bc", "status": "None", "id": "5fa919f9292a8300019349b9", "createdTime": "2020-11-09T10:29:13.928Z", "creatorUserId": "5af5a8dc-8cb0-40f9-ac99-ca2533fa4491", "editedTime": "2020-11-13T15:58:45.69Z", "editorUserId": "5af5a8dc-8cb0-40f9-ac99-ca2533fa4491" }
The directory identifier from the example above is
5fa919f9292a8300019349b9
.To get a list of files in a directory, make a
GET
request tohttps://fastreport.cloud/api/rp/v1/Templates/Folder/{id}/ListFiles?skip=0&take=10
, substituting{id}
with the directory identifier.A sample request.
curl -X GET "https://fastreport.cloud/api/rp/v1/Templates/Folder/5fa919f9292a8300019349b9/ListFiles?skip=0&take=10" -H "accept: text/plain"
A sample response.
[ { "reportInfo": { "author": null, "created": "2020-12-04T10:58:57Z", "creatorVersion": "20.20.4.1", "description": null, "modified": "2020-12-04T11:00:20Z", "name": null, "picture": null, "previewPictureRatio": 0, "saveMode": "All", "savePreviewPicture": false, "tag": null, "version": null }, "name": "template.frx", "parentId": "5fa919f9292a8300019349b9", "tags": null, "icon": null, "type": "File", "size": 17159, "subscriptionId": "5fa919fa292a8300019349bc", "status": "Success", "id": "5fc9ece6b792c90001d94b13", "createdTime": "2020-12-04T08:01:42.708Z", "creatorUserId": "5af5a8dc-8cb0-40f9-ac99-ca2533fa4491", "editedTime": "2020-12-04T08:01:42.708Z", "editorUserId": "5af5a8dc-8cb0-40f9-ac99-ca2533fa4491" } ]
The template identifier from the example above is
5fc9ece6b792c90001d94b13
.To prepare a report, you need a directory where you can place the report. To get the root report directory, make a
GET
request tohttps://fastreport.cloud/api/rp/v1/Reports/Root
.A sample request.
curl -X GET "https://fastreport.cloud/api/rp/v1/Reports/Root" -H "accept: text/plain"
A sample response.
{ "name": "RootFolder", "parentId": null, "tags": null, "icon": null, "type": "Folder", "size": 16384, "subscriptionId": "5fa919fa292a8300019349bc", "status": "None", "id": "5fa919f9292a8300019349ba", "createdTime": "2020-11-09T10:29:13.993Z", "creatorUserId": "5af5a8dc-8cb0-40f9-ac99-ca2533fa4491", "editedTime": "0001-01-01T00:00:00Z", "editorUserId": null }
The directory identifier from the example above is
5fa919f9292a8300019349ba
.To prepare a report, make a
POST
request tohttps://fastreport.cloud/api/rp/v1/Templates/File/{id}/Prepare
, substituting{id}
with the template identifier.Send JSON in the body of the request according to the scheme below.
{ "name": "string", "parentFolderId": "string", "reportParameters": { "additionalProp1": "string", "additionalProp2": "string", "additionalProp3": "string" } }
parentFolderId
— the directory identifier where the report will be placed.name
— the name of the output file. Add the extension.fpx
manually.reportParameters
— parameters that are specified in the report itself using the report designer; in this example, they are not required.
A sample request.
curl -X POST "https://fastreport.cloud/api/rp/v1/Templates/File/5fc9ece6b792c90001d94b13/Prepare" -H "accept: text/plain" -H "Content-Type: application/json-patch+json" -d "{ \"name\": \"awesome_report.fpx\", \"parentFolderId\": \"5fa919f9292a8300019349ba\"}"
A sample response.
{ "templateId": "5fc9ece6b792c90001d94b13", "reportInfo": null, "name": "awesome_report.fpx", "parentId": "5fa919f9292a8300019349ba", "tags": null, "icon": null, "type": "File", "size": 16384, "subscriptionId": "5fa919fa292a8300019349bc", "status": "InQueue", "id": "5fe4614bcd7c55000148e4c6", "createdTime": "2020-12-24T09:37:15.7169531+00:00", "creatorUserId": "5af5a8dc-8cb0-40f9-ac99-ca2533fa4491", "editedTime": "2020-12-24T09:37:15.7169582+00:00", "editorUserId": "5af5a8dc-8cb0-40f9-ac99-ca2533fa4491" }
Note that the file has the
InQueue
status, which means that a build task was created and got into the builder's queue; at this stage, the report received its identifier5fe4614bcd7c55000148e4c6
for the process.Wait for a while, until the report is prepared.
To get information about the report, make a
GET
request tohttps://fastreport.cloud/api/rp/v1/Reports/File/{id}
, substituting{id}
with the report identifier.A sample request.
curl -X GET "https://fastreport.cloud/api/rp/v1/Reports/File/5fe4614bcd7c55000148e4c6" -H "accept: text/plain"
A sample response.
{ "templateId": "5fc9ece6b792c90001d94b13", "reportInfo": null, "name": "awesome_report.fpx", "parentId": "5fa919f9292a8300019349ba", "tags": null, "icon": null, "type": "File", "size": 16927, "subscriptionId": "5fa919fa292a8300019349bc", "status": "Success", "id": "5fe4614bcd7c55000148e4c6", "createdTime": "2020-12-24T09:37:15.716Z", "creatorUserId": "5af5a8dc-8cb0-40f9-ac99-ca2533fa4491", "editedTime": "2020-12-24T09:37:15.716Z", "editorUserId": "5af5a8dc-8cb0-40f9-ac99-ca2533fa4491" }
Take note of the file’s
Success
status. The report has been successfully built.To download the report, make a
GET
request tohttps://fastreport.cloud/download/r/{id}
, having replaced{id}
with the report identifier.A sample request.
curl -X GET "https://fastreport.cloud/download/r/5fe4614bcd7c55000148e4c6" -H "accept: text/plain"
The file will be received in response.