Upload new template
Products: FastReport Cloud, FastReport Corporate Server, FastReport Publisher
One of the main features of Service solutions is storing templates, reports, and other data in the cloud. This article will describe how to upload your own template to service solution template storage.
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.
Instruction
You need to get the root folder ID of the workspace. This identifier will never change, so you can save it and you do not need to request the ID every time before uploading a new template.
To request the root directory, execute the
GETrequest to{host_name}/api/rp/v1/Templates/Root.curl -X GET "{host_name}/api/rp/v1/Templates/Root" -H "accept: text/plain"In this case, the directory for the default workspace will be returned. You can specify a particular workspace by passing the
subscriptionIdparameter.curl -X GET "{host_name}/api/rp/v1/Templates/Root?subscriptionId=your_workspace_id" -H "accept: text/plain"Example answer:
{ "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" }Directory ID from the example above:
5fa919f9292a8300019349b9.To upload the desired template, execute the
POSTrequest to{host_name}/api/rp/v1/Templates/Folder/{id}/File, where the directory ID should be substituted for{id}and JSON should be passed in the request body according to the scheme below.{ "name": "string", "content": "base64encoded(template.frx)" }name— name of the file to be displayed in the user panel.Add the
.frxextension to the file name manually.content— file content encoded in base64.
Example request:
curl -X POST "{host_name}/api/rp/v1/Templates/Folder/5fa919f9292a8300019349b9/File" -H "accept: text/plain" -H "Content-Type: application/json-patch+json" -d "{ \"name\": \"template.frx\", \"content\": \"77u/PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXR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"description": null, "modified": "2020-12-04T11:00:20", "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.7087229+00:00", "creatorUserId": "5af5a8dc-8cb0-40f9-ac99-ca2533fa4491", "editedTime": "2020-12-04T08:01:42.7087112+00:00", "editorUserId": "5af5a8dc-8cb0-40f9-ac99-ca2533fa4491" }Now this template can be used to prepare (create) a report and export it.