Configuring the REST Connection:
- For my use case, the goal is to start a Qlik Sense Task. The endpoint used is https://<ServerName>:4242/qrs/task/start?name=<TaskName> which uses a POST request that returns no data.
- The Authentication Schema is 'Anonymous'
- The exported Client.pfx certificate was added to the request
- For the Additional request parameters:
- Query parameters needs the xrfkey - value included e.g. xrfkey - ichbineinberlinR
- Query headers needs X-Qlik-XrfKey and X-Qlik-User headers included e.g. X-Qlik-XrfKey - ichbineinberlinR and X-Qlik-User - UserDirectory=internal; UserId=sa_api
- If the parameters are correct, clicking either the Test Connection or Save buttons will not error but instead perform the API Request
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';
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 ran.
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 URLLet vServer = 'localhost';
Let vTaskName = 'Reload Operation Monitor';
Let vURL = '"https://$(vServer):4242/qrs/task/start?name=$(vTaskName)"';
LIB CONNECT TO 'Trigger Task';
FROM JSON (wrap on) "root"
WITH CONNECTION ( URL $(vURL) );
Drop Table RestTable;