Qlik Sense documentation and resources.
To resolve rest connector related issues visit:
Revised Sense Sample to include updated cookie parsing and proper error handling
Added sample to trigger an NPrinting User Import Task from Qlik Sense
One of the most common questions is how can i distribute my NPrinting reports to occur automatically as soon as my Qlik app is done reloading ?
THis is possible in both Qlik Sense and with QlikView using the NPrinting API. Moreover, you can invoke the API through the the Qlik load script Qlik REST Connector v1.3+. What this means is that you can schedule and/or chain your NPrinting report distributions using the Qlik Sense scheduler or the QlikView publisher to better integrate the operations across the platform
.The sample included herein draws on the great document published by gianluca perrin on Qlik Community here: https://community.qlik.com/thread/292037
Should the NPrinting task, publisher has a built in solution to notify administrators. Qlik Sense also has 3rd party solutions to do the same.
You need to have v1.3 of the Qlik REST Connector. Its available as of Feb 2018.
You will need to create two REST Connector connections to the NPrinting API. One that uses a default HTTP method of "GET" , the other will use "POST" as the default method.
Please reference pages 8-9 of the document https://community.qlik.com/thread/292037 to create the two connections.
1. Import the attached application and open the script in the Data Load Editor
2. Modify the SETUP tab to reflect your
i. on lines 25/26 update the names of the two REST Connections that you create using the steps in 'Connection Setup' above.
ii. on line 30 , if NPrinting is configured to use https (it is by default) leave this setting to 'Yes' . If you reconfigured it to use http , set to 'No'
iii. On line 31 , set the NPrinting server and endpoint (host + port)
iv: Line 35 is the name of the NPrinting Publish Task that you want to execute
v: Line 37 and 38 is an enhancement to have Qlik check the NPrinting task executions for errors, or , if it runs too long, to abort it and report a failure .
3. (optional) You can also Import the following application into Qlik Sense to send an administrative alert. THis is not necessary with QV Publisher as it has an in-built feature to notify administrators when a publish task fails.
4. Open the imported app in the data load editor and update the 'setup' section
i. on lines 21/22 update the names of the two REST Connections that you create using the steps in 'Connection Setup' above.
ii. on line 26 , if NPrinting is configured to use https (it is by default) leave this setting to 'Yes' . If you reconfigured it to use http , set to 'No'
iii. On line 37 , set the NPrinting server and endpoint (host + port)
iv: Line 32 is the name of the NPrinting Publish Task that will alert an administrator about a report failure
(note that i've toyed with using the Notification Web Connector to send an administrative email alert in the event of a full blown NPrinting outage. This sample is a little simpler)
In Qlik Sense QMC under tasks i've setup 3 tasks .
Task #1 - reloads a Qlik App
Task #2 - Distributes reports in an NPrinting Publish task (this is chained to execute 'on success' of Task #1)
Task #3 - Send an Administrator alert (this is chained to execute 'on failure' of Task #2)
The QLikVIew solution has all the same benefits as the Qlik Sense solution with a couple more benefits.
- you can pass the vTask name from the publisher task to make for greater re-usability of the load script for chaining multiple tasks
- Publisher has a built in admin notification feature. SHould the NP task fail, the publisher task will also fail and an admin notification will be sent (you can do that with qlik sense but need to use a 3rd party qlik sense task notification solution, or use the load script to call an administrative task to send a notification. The latter can be done with NPrinting or with the Qlik Web Notification Connector.
The QlikView load script has a login , get task ID (lookup using task name), post task execution, and a task execution check tab. The task execution check tab will monitor the NP task execution on an interval with a configurable timeout. Should the NP task throw a warning or error, it errors out the publisher task. Should the NP task exceed the timeout, it kills the NP task and errors out the publisher task.
You will need to update the NPServer, Task and timeout settings in the CONFIG tab. Again use the REST Connector 1.3 and i suggest testing with QV desktop first . The REST Connector must be manually installed on QV desktop and on the publisher machine to work.
New cookie parsing:
//Set Cookie header
let vCookieRaw = peek( 'Set-Cookie',0,'_response_header');
if vSSL='False' then
let vCookie= subfield(subfield('$(vCookieRaw)','Path=/,',3),';',1);
// let vCookie = TextBetween('$(vCookieRaw)','Secure,','Path=/',2);
Let vCookie = TextBetween('$(vCookieRaw)','SameSite=None,','; Path=/',3);
I have followed the above mentioned steps but not getting below script. Am I missing any steps to achieve it?
FROM "items" FK "__FK_items")
FROM JSON (wrap off) "data" PK "__KEY_data"
WITH CONNECTION( URL "$(vEndpoint)", HTTPHEADER "cookie" "$(vCookie)",
QUERY "Limit" "1000000",);
Thank you for the script.
Now I have a query.
How to trigger multiple tasks from the given script.
First of all, thank you for post
I would like your help, I am trying to use your .qvw app, and just change the npserver domain and I get the error:
QVX_UNEXPECTED_END_OF_DATA: Response headers are denied by the current connection. Please edit your connection in order to enable response headers loading.
If I continue the script I have other error:
QVX_UNEXPECTED_END_OF_DATA: HTTP protocol error 403 (Forbidden):
Could you please help me, I don't know API or Qlik Connector REST it's my first time.
I get the same error - already found a solution?
Thank You! 🙂
I have followed all the steps and it is working perfectly fine now. In the Query Header, I have mentioned Origin Under Name and my server host name and it worked.
Kindly go through step by step and it will work fine.
I am trying to trigger N-Printing API through Qlik-Sense Script. REST Connector for GET/POST Connection is successful. I am also able to Authenticate and get the Cookie. But When i am trying to call Apps List api I am getting error saying HTTP Protocol error 403(Forbidden) The server refused to fulfill the request.
I am getting 2 cookies instead of 3 like mentioned in document.
I am using Https for bot qlik sense and Nprinting.
Can some one please help.
Did you find a solution for this. I also get 2 cookies instead of 3
still having issues ?
Do we need to update all the below to get this work?
nPrinting : Qlik NPrinting February 2018 SR1
Qliksense: Qliksense Feb 2019
Rest Connector: 2.0.6