How to generate and access a report with REST API
This guide will show you how to obtain and access a report that contains data, using REST API.
Requisites
The Report REST API resource requires the following information when using it:
- Read how to enable REST API
- Read how to generate the REST API token
- Read how to obtain an application ID
Resources used
- Report > reports - to get the reportID
- Report > renderings - to get the renderingID
- Report > renderingsID:long - to get the report link (where the report data lies).
Get the reportID
The first step is obtaining the reportID.
1. Log in to http://host_name/comGpsGate/api/v.1/test
Note: replace host_name with your actual server IP address or DNS name.
2. Click on the resource name reports, and select Try it out
/applications/{applicationid:int}/reports
3. Fill the applicationID, then click on Execute
4. You will get a list of reports with their default parameters.
Save the applicationID for later use.
Note: keep the model open to use the data for the next resource.
Get the renderID
Now we need to generate a render of the report and optain its renderID. For that we'll use the following resource:
/applications/{applicationid:int}/reports/{reportid:int}/renderings
1. Click on Try it out
2. Fill in the model data (with the required parameters) to obtain the renderID, then click on Execute.
Note: if you need help with your model, we recommend you using the resource: /applications/{applicationid:int}/reports/{reportid:long} this resource generates a model with parameters needed in this step.
- Use the parameter "reportFormatId": 2 if you want to generate your report in CSV format.
3. You should get a response. The renderID is the one marked in red:
Get the report
Finally, we will use the following resource to get the report
1. Click on Try it Out
2. Fill in the ApplicationID, ReportID and RenderingID obtained in previous steps:
3. Click on Execute
4. In the results you will get the link of the report.
5. Compose the URL using your server + the link