Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
May 22, 2018 1:28:36 PM
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
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
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
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
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)
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
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.
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