How to invoke a Qlik Sense task from the command line

Qlik Sense Task Column Menu

If you use Qlik Sense, eventually you will need to automate the execution of the data loading tasks.

Qlik Sense implements a REST API to make this and much more things. It is called Qlik Sense Repository Service API or QRS API

There are several ways to authenticate our calls to the server. Here we will use a server certificate instead of Windows or HTTP Header Authentication.

To export the server certificates, we need to access the QMC console with admin privileges. Once you are logged into the QMC, click in the last option on the left menu “Certificates”.

Exporting Qlik Sense server certificatesYou will need to enter a machine name and also a password if you want to protect your certificate. Remember, if you don’t specify a password, anyone who has access to the certificate file will have the capabilities of an admin via the Qlik Sense API.

Change the file format of the certificate to .pem and note the location where the .zip file that contains the certificates will be saved.

If you go now to the folder mentioned above and everything went ok, you will find a zip file. Unzip the file and copy both files inside (client.pem & client_key.pem) into a safe folder or an usb pen that we will reference later. 

Now, let’s go to our Linux station to create the utility script that we can use to start Qlik Sense tasks.

Of course, the Qlik Sense server has to be accessible from this station.

1.- Create a folder to store both the script and the certificate files

mkdir /opt/qliktasks

2.- Access the new folder and create a new one to store the certificate files

cd /opt/qliktasks

mkdir cert

3.- Copy the cert files from your usb device or the folder where you stored them before. Once you’ve finished, there should be two files inside the cert folder you created in step 2.

/opt/qliqtasks/cert/client.pem

/opt/qliqtasks/cert/client_key.pem

4.- Now, let’s create the sh script:

4.1.- Inside /op/qliktasks folder open nano or vim to create the file taskStart.sh

nano taskStart.sh

4.2.- Make up a 16 characters long key that you will specify later in the query string and a header of the curl request. For instance:

MySixteenLongKey

1234567890123456

4.3- Copy the following content inside the file updating the files path and the 16 long key. This is a very important step because the files need to be specified with an absolute path.

#!/bin/bash

curl --key /opt/qliqtasks/cert/client_key.pem \
--cert /opt/qliqtasks/cert/client.pem \
--insecure \
-X POST \
https://myserver.intra.net:4242/qrs/task/$1/start?xrfkey=MySixteenLongKey \
--header "Content-type:application/json" \
--header "x-qlik-xrfkey: MySixteenLongKey" \
--header "X-Qlik-User: UserDirectory=internal;UserId=sa_repository" \
-d ""

4.4.- Save the file (CTRL + O), confirm and exit (CTRL + X) the editor

4.5.- Activate execution flag

chmod +x startTask.sh

5.- Now we are ready to execute a Qlik Sense task by specifying its UUID.

./startTask.sh e12ed06d-9124-4772-a07d-60cc06f05521

How to find the task UUID?

Go to QMC tasks panel and find the column menu in the top right corner. Simply activate the ID checkbox and copy from the new column the UUID of the task you need to invoke.

Qlik Sense Task Column Menu

3 thoughts on “How to invoke a Qlik Sense task from the command line”

  1. I Hope this will work for Qliksense cloud,
    I am new to this Qliksense, I have to create a job to trigger the Qliksense application from Unix. Is it possible firstly?. I have few basic questions,
    1. How to access qliksense server from unix server.
    2. How to get this key “Make up a 16 characters long key that you will specify later in the query string and a header of the curl request.” Is it a key created by us.
    3. For the app created in Qliksense, do we get the UUID? By that UUID can we trigger Qliksense job from Unix.

    1. Hi Upendra,

      I can’t answer if this will work on cloud or not. I guess the only issue you can face is not having the server certificate (but maybe there is a way to get it)

      1.- The instructions given in the post are for a unix machine.
      2.- Yes, it is created by you. It has to be 16 chars long
      3.- The UUID you have to use is the UUID of a task, not an APP UUID. A Qliksense application cannot be invoked, but a task that executes the data loadings for an app can be.

      I encourage you to take a look to https://www.pangodream.es/how-to-invoke-a-qlik-sense-task-from-node-js . It could help you as well.

      Regards and thanks for commenting.

Leave a Reply

Your email address will not be published. Required fields are marked *