Page 1 of 1

JSON Datasource -> Add Variables to URL?

Posted: Wed Nov 03, 2021 6:34 pm
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

Re: JSON Datasource -> Add Variables to URL?

Posted: Fri Nov 05, 2021 2:47 pm
by Lech Kulikowski
Hello,

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

Thank you.

Re: JSON Datasource -> Add Variables to URL?

Posted: Fri Nov 05, 2021 5:31 pm
by mikemaat
Stimulsoft.Reports.Web 2021.1.1

Re: JSON Datasource -> Add Variables to URL?

Posted: Mon Nov 08, 2021 1:29 pm
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.