JSON Datasource -> Add Variables to URL?

Stimulsoft Reports.WEB discussion
Post Reply
mikemaat
Posts: 9
Joined: Mon Jul 12, 2021 9:58 pm

JSON Datasource -> Add Variables to URL?

Post by mikemaat »

In my report I have a json data source that gets the json from an API endpoint we have constructed externally. For this example, we'll say that its https://myapi.com/GetMyJsonFile. This endpoint returns an array of records from a database in json format.

In the report I also have two variables: FromDate and ToDate. What I want to do, is being able to strap the values from these variables into the JSON url so that the endpoint can filter the results it queries before returning them
i.e.. ../GetMyJsonFile?from_date={FromDate}&to_date={ToDate}

Anyone got any tips how this could be done? I know we can do this with SQL queries by adding the variables like {MyVariable} in the query, but it doesnt seem to work for JSON datasource URLs. Is there an event I can tap into that occurs after variable values have been selected, but before the datasources are loaded so that I could modify the json datasource path value?

Image
Lech Kulikowski
Posts: 6198
Joined: Tue Mar 20, 2018 5:34 am

Re: JSON Datasource -> Add Variables to URL?

Post by Lech Kulikowski »

Hello,

You can use variables in the path to JSON.
Please clarify which product, version are you use?

Thank you.
mikemaat
Posts: 9
Joined: Mon Jul 12, 2021 9:58 pm

Re: JSON Datasource -> Add Variables to URL?

Post by mikemaat »

Stimulsoft.Reports.Web 2021.1.1
Lech Kulikowski
Posts: 6198
Joined: Tue Mar 20, 2018 5:34 am

Re: JSON Datasource -> Add Variables to URL?

Post by Lech Kulikowski »

Hello,

In the Web version, you can use the OnGetReportData in which get data with necessary parameters:
https://www.stimulsoft.com/en/documenta ... _event.htm

Thank you.
Post Reply