Report parameters
Products: FastReport Cloud, FastReport Corporate Server, FastReport Publisher
This article covers the process of passing parameters to a report, which are a dictionary of parameters provided when generating a report. More information on this can be found in the FastReport .NET guide in the Report parameters section.
Getting started
You will need the following tools and facilities:
Know how to use API key in Service solutions.
This article will skip over additional information on authentication and authorization.
Curl tool.
Any other REST client will work, but the examples will be built for curl.
Report template.
It can be created in the free FastReport Community Designer program.
Active subscription to one of the following products: FastReport Cloud, FastReport Corporate Server, or FastReport Publisher.
Internet access.
Pass parameters to the report
Parameters can be passed when:
- preparing a report;
- exporting from a template;
- working with tasks.
Let’s consider parameter passing on the example of report generation. Detailed instructions on how to create a report can be found in the Create report section.
To create a report, execute the POST request to the {host_name}/api/rp/v1/Templates/File/{id}/Prepare, where the template ID should be used instead of {id}.
In the request body, pass JSON according to the scheme below.
{
"name": "string",
"folderId": "string",
"reportParameters": {
"additionalProp1": "string",
"additionalProp2": "string"
}
}
folderId— ID of the directory where the report will be placed.name— name of the resulting file. Add.fpxextension manually.reportParameters— parameters that are specified in the report itself using the report designer.
If you do not specify folderId, the generated report will be saved to the root folder.
Example request:
curl -X POST "{host_name}/api/rp/v1/Templates/File/5fc9ece6b792c90001d94b13/Prepare"
-H "accept: text/plain"
-H "Content-Type: application/json-patch+json"
-d "{
"name": "awesome_report.fpx",
"folderId": "5fa919f9292a8300019349ba",
"reportParameters": {
"Parameter1": "Value1",
"Parameter2": "Value2"
}
}"
Example answer:
{
"templateId": "5fc9ece6b792c90001d94b13",
"name": "awesome_report.fpx",
"parentId": "5fa919f9292a8300019349ba",
"type": "File",
"size": 16384,
"subscriptionId": "5fa919fa292a8300019349bc",
"status": "InQueue",
"statusReason": "None",
"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"
}