Skip to main content Skip to footer

How to Pass Report Parameters as Path Parameters to your REST API Endpoint

Before you read: This guide utilizes a REST API endpoint with path parameters. For demonstration purposes, the article uses the following sample data endpoint: https://demodata.grapecity.com/northwind/api/v1/customers/{@CustomerId}

 

With ActiveReportsJS, it is possible to directly pass a report parameter to your data source to filter the results at runtime. To do this in the Report Designer, we can follow this procedure: 

  1. Navigate to the Parameters section in the designer and add a new report parameter. Let's name it CustomerId and give it a prompt that says Select Customer Id. Add some available values to the parameter under the Non-Queried section such as ALFKI, ANATR, and ANTON.
  2. Set up the data source on the report to use the remote JSON endpoint mentioned at the beginning of this article. Afterwards, click the plus icon to add a data set to the report. Input $ into the Json path and click validate. If the report asks for a CustomerId, input ALFKI and save the changes. 
  3. Drag a table control onto the design surface and drag the customerId, contactName, and companyName fields from the data set into the detail row cells. Adjust the column sizes so that all the data fits, and preview the report to confirm that the data is being filtered properly.

 

Congratulations -- you have successfully set up a dynamic REST API endpoint that takes a report parameter as a path parameter to filter the data at runtime. If you'd like some more help, please open a support ticket and our engineering team will help you further.

Christian Wirt