There are situations where you would like to know something from the system configuration (QMC) from inside of a load script, something like "Trigger task", "Check status of a task" or much more. You can do that directly by consuming the QRS Api within your load script.
In theory, the QRS API operates on the https port 443 as well as on port 4242. If you used the latter, you have to present the public key of the server certificate, which cannot be done from the load script (remark added 2020: the REST Connector meanwhile allows to add a Certificate File and Key File, so you can setup a connection directly to port 4242 when allowed from a firewall point of view).
In order to use the port 443, you need to authenticate as a privileged user towards the server - your best bet from the script is to use the header authentication (pass the userid via http-header) and this requrires the setup of a Virtual Proxy on the server by a QMC admin.
We want the script to be able to query the QRS api, so we have to give it a new "door" to authenicate. Set up a new Virtual Proxy like this: There will be a static pseudo user directory which we call "APIUSERS", whereas the user id itself will be provided in a http-header.
Dont forget to
Note: We will have to come back to QMC/Users once again after making the first call using the header.
It is literally impossible to go straight to the REST connector from the script if you haven't tried the results from a tool that shows all response details (return code, possible error messages etc). My tool of choice is "Postman" (the app, not the Chrome-Plugin of the same name)
Lets use the server url + /header/ (this is the virtual proxy we created) + /qrs/about + &xrfkey= and a 16 digit combination, which you repeat in the http-headers under the key "X-Qlik-xrfkey" again. Also provide the userid as a 2nd http-header
You should get an answer like above in Json format. This means, you made it through the virtual proxy. A new user has been added to the QMC, namely the id "scriptload" (coming from the http-header) with the directory "APIUSERS" (coming from the virtual proxy setting).
Go back to the QMC and provide the new user the Role "AuditAdmin"
Now you can also query some details about the app. Try the following request, before we finally go to the Load Script. -.../qrs/app/full should provide all information about apps, including possible tags.
In order to get the details about one specific app you should use the "filter=" query-string, the syntax is like the Json object key, a comparison operator, and a constant. In my case: id eq <app-guid>
eq is "equals", don't use "=" which is a reserved character already used at "filter="
The provided Qlik QRS Utility app provides you already a nice script interface with which you can already do some nice stuff against the QRS API. I have build it up by managing the Qlik TASKS via the Qlik load script and be able to do calls like:
The app contains multiple sections with the procedure logic to consume the QRS API and a START section where we call the single procedure to accomplish the desired result. As you can see from the screenshot below the procedures are exposing some standard input params like: