[resolved] REST API: Get request with query params to get report
-
Guys, I'm now nearly finished with my first report that is getting the data from our cloud and for each record it generates a page in the pdf. so far so good, but now I'd like to be able to provide the link to the end user, similar to what you have already implemented:
https://serverandport/templates/BJ-J_fGxQThat link will generate the whole report.
What I'm after is if there is any way to provide the data to that report via GET, similarly to
https://serverandport/templates/BJ-J_fGxQ?data={itemid: 'someid'}that would trigger the report that would query our cloud db for the record with the particular itemid.
I know I can achieve this with the POST, but that is not as handy as with GET.
Thank you and with regard
-
So far I don't see a good place where to put this to the documentation, so it is mentioned just in this blog post.
See Query string parameters
-
Hi Jan,
that sounds very promising, but I'm on 1.9.2 (our prod) I reckon it's not supported on < 2.x ?
cheers
-
Yes this works out of the box only in v2.
Here you can find a solution for v1
https://github.com/jsreport/jsreport/issues/218#issuecomment-222631879
-
thanks heaps. posting other question though..
-
Is this approach still valid for 1.10 as it seems like jsreport.config.js is not being picked up as I'm constantly getting undefined for the $query object. Thanks
<servername>:5488/templates/r1lA5xRgQ?objectid=5
Folder structure:
d:\jsreport
|---- \data
|---- \logs
|---- \jsreport.config.json
|---- \jsreport.config.js
|---- \jsreport.exe
|---- \queryString.js
-
You need to enable the extension auto discovery for
jsreport.exe
in thejsreport.config.json
using{ "discover": true, }
https://jsreport.net/learn/single-file-executable
The jsreport executable have its own set of predefined extensions (in the same way that jsreport does), if you want to use a custom extension that is not included by default, for example jsreport-wkhtmltopdf, you will need to install the extension using npm install jsreport-wkhtmltopdf and then create a jsreport config file (if you don't have one yet), add discover: true option to your config:
-
Thanks. Need to pay more attention to the particular doco but I'm facing so many issues that I can easily miss a crucial info.
-
No problem. I just wanted to link the particular section in docs. Not to blame you. :)
-
This post is deleted!