Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Mar 18, 2022 9:55:41 AM
Apr 5, 2018 9:41:51 AM
Typically the Qlik REST Connector is used for situations where data will be returned and used within a Qlik Sense App. Use cases have been described where it is ideal to be able to perform actions like starting a Qlik Sense Task depending on if certain values are returned by other Data Connections. This would usually be scripted outside of the Qlik Sense script using our API endpoints. However, with minor changes, it can be performed inside the Qlik Sense script itself.
Qlik Sense Enterprise on Windows
Configuring the REST Connection:
Making the call within the script:
Typically, after making a new Data connection, the 'Select Data' button would be used to select the fields that would be added to the script. In my use case, the endpoint I used returns no values so there was nothing to add to the script. To use this new data connection in the script, the Connector needs to think it will be searching for Data and hit our endpoint looking for this data. I added the following query to my script that returns no data from a non-existent "Root" table:
LIB CONNECT TO 'Trigger Task';
RestTable:
SQL SELECT
FROM JSON (wrap on) "Root";
Drop Table RestTable;
Now, when the document is reloaded, the endpoint will be hit (my task will be reloaded), no data will be returned, a table will be created/dropped and the rest of the script will be run.
Advanced:
Here is a more advanced script that will allow you to dynamically change the URL with variables:
In the Data connection created, check the "Add missing parameter to final request" check box to ensure the xrfkey query parameter will be added to the custom URL
Let vServer = 'localhost';
Let vTaskName = 'Reload Operation Monitor';
Let vURL = '"https://$(vServer):4242/qrs/task/start?name=$(vTaskName) "';
LIB CONNECT TO 'Trigger Task';
RestTable:
SQL SELECT
FROM JSON (wrap on) "root"
WITH CONNECTION ( URL $(vURL) );
Drop Table RestTable;
Hello @jpjust
Please post about your issue in the appropriate forum: Qlik Sense Integration, Extensions, & APIs.
All the best,
Sonja