Skip to main content

How do I call QlikSense APIs with curl (QMC Task load)

No ratings
cancel
Showing results for 
Search instead for 
Did you mean: 
olivieresmieugi
Contributor
Contributor

How do I call QlikSense APIs with curl (QMC Task load)

Last Update:

May 22, 2018 1:28:36 PM

Updated By:

olivieresmieugi

Created date:

May 22, 2018 1:28:36 PM

Hello all

As I am a newbie with PowerShell, and always reluctant to add some complementary tools (eg Qlik-Cli), i tried to call APIs by using curl

. As I have been frustrated by the doc in the support website, here is the procedure to make things work . Hope it will help some..

The goal is actually to run a Task Load in the QMC


Install Curl

Can be useful 😉

* Curl Download Wizard

   https://curl.haxx.se/dlwiz/

or https://curl.haxx.se/dlwiz/?type=bin&os=Win64&flav=-&ver=-&cpu=x86_64

* doc for installing:  https://code.i-harness.com/fr/q/911219

* Official Curl website https://curl.haxx.se/docs/httpscripting.html

I installed it there :%UserProfile%\AppData\Local\curl-7.59.0-win64-mingw\bin

Test

See  https://help.qlik.com/en-US/sense-developer/September2017/Subsystems/RepositoryServiceAPI/Content/Re...

BUT there is a missing parameter:"  --key path\client_key"


In Dos, in my bin Repository

curl -v ^

--location ^

--cert C:\Users\MyUserName\..\client.pem ^

--key C:\Users\MyUserName\..\client_key.pem ^

--insecure https://MyQlikServerName:4242/qrs/app?xrfkey=0123456789abcdef ^

--header "x-qlik-xrfkey: 0123456789abcdef" ^

--header "X-Qlik-User: UserDirectory=Internal;UserId=sa_repository"


Task Load

See

https://help.qlik.com/en-US/sense-developer/February2018/Subsystems/RepositoryServiceAPI/Content/Rep...

Note, for me:  /qrs/task/{id}/start/synchronous => qrs/task/{58b31b78-ad2d-456c-bc01-5356a34c6ee7}/start/synchronous

In Dos, in my bin Repository

curl -v ^

--location ^

--header "Transfer-Encoding: chunked" ^

--cert C:\Users\MyUserName\..\client.pem ^

--key C:\Users\MyUserName\..\client_key.pem ^

--request POST ^

--insecure https:/MyQlikServerName::4242/qrs/task/58b31b78-ad2d-456c-bc01-5356a34c6ee7/start/synchronous?xrfkey=0123456789abcdef ^

--header "x-qlik-xrfkey: 0123456789abcdef" ^

--header "X-Qlik-User: UserDirectory=Internal;UserId=sa_repository"



Chrs

Olivier

Comments
armandfrigo
Partner Ambassador
Partner Ambassador

In case others, like me, don't want to use certs (root admin) for obvious security reasons when developers call the QRS API with cURL, here is the process through Windows authentication. Windows authentication ensures users calling the QRS API will have same permissions as through QMC.

The key is to first get the session cookie from any GET query, store it and reuse it when sending a POST query, i.e. like to trigger task.

How to start a Qlik task with cURL (Windows authentication)

  • First send GET request to the About endpoint in order to store the session cookie

curl -L --ntlm --negotiate -u : --insecure --header "x-qlik-xrfkey: 0123456789abcdef" --header "User-Agent: Windows" -H "Content-type:application/json" -c QlikCookie.txt https://ServerName/qrs/about?xrfkey=0123456789abcdef

  • Send a POST request to trigger a task, passing the session cookie

curl -L --ntlm --negotiate -u : --insecure --header "x-qlik-xrfkey: 0123456789abcdef" --header "User-Agent: Windows" -H "Content-type:application/json" -b QlikCookie.txt https://ServerName/qrs/task/{Task ID}/start/synchronous?xrfkey=0123456789abcdef -d "foo"

It is enough to match the header and query xrfkey, so make your own for security reasons again.

0 Likes
chinnred
Contributor
Contributor

Did you get the output for this command ?

 

Can you confirm me if the command output is same as QMC task output ?

 

If your getting, request you to please provide me the command 

0 Likes
Version history
Last update:
‎2018-05-22 01:28 PM
Updated by: