Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
***UPDATED 06/30/2021
To resolve rest connector related issues visit:
**UPDATED 10/16/2020
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
Benefits
Should the NPrinting task, publisher has a built in solution to notify administrators. Qlik Sense also has 3rd party solutions to do the same.
Restrictions
You need to have v1.3 of the Qlik REST Connector. Its available as of Feb 2018.
Sample
Connection setup
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.
App Setup
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)
Task setup
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)
QLIKVIEW
The QLikVIew solution has all the same benefits as the Qlik Sense solution with a couple more benefits.
Additional 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.
Load script
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);
else
// let vCookie = TextBetween('$(vCookieRaw)','Secure,','Path=/',2);
Let vCookie = TextBetween('$(vCookieRaw)','SameSite=None,','; Path=/',3);
end if
Related information:
Hey guys,
need a quick help with my API.
I believe I've forgot to put look up few details in the instruction, because instead of sending all of my 12 publish tasks, API just loads only 1.
I am using latest versions of Qlik Sense and Nprinting. API is derived from Gialuncas instructions.
If you have any idea what could be possibly wrong, please let me know.
Thanks
Bernard
Are you trying to trigger the same task 12 times ? Or are they 12 different tasks ? Are you trying to trigger the 12 different tasks from one Qlik load script ? Or are you using 12 different load scripts ?
Try testing the script with the 'debug' feature and execute the script line by line while monitoring the 'task executions' page in nprinting. tasks are not sent if there are no recipients of the task . that's a common problem if you are using the script to update recipients at the same time.
I am trying to run 12 different tasks(with different recipients)from one load script, connected to single connection.
When I check the log, "NP GET Task" can see all 12 task, but in execution via "NP POST Task execution" it will run just 1 task out of 12.
As per my understanding of the API I presumed this should detect all 12 tasks and run them all, shouldn't it?
No.
Each unique task has separate Task ID. When you POST a task execution you need to pass the Task ID of the task you want to execute .
You will need to submit 12 different task executions each with a different Task ID.
I'd recommend doing them in 12 different qlik load scripts. That way if one fails, you will get a unique notification of which task failed.
@JonnyPoole yes , I still having issues but I guess I have to upgrade to get this working.
which version are you on ? We recently backported the REST Connector Fix to February 2019 SR4 as well. So if you are on an otherwise working version of February, you can just apply the patch to Qlik Sense as well. The bug was found many versions ago, fixed , but then reappeared in Feb 2019.
-------
REST Connector cannot load data from NPrinting API after upgraded to June 2017 release
Jira issue ID: QVXREST-837
Description: A connection successfully reloaded data in Qlik Sense 3.2.4. But after upgrade to June 2017 and later September 2017 release, the reload does not work anymore in either version. This issue is a duplicate of QVXREST-593.
@JonnyPoole 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
You need to update Qlik Sense. Either install the latest Qlik Sense version (June) or apply Qlik Sense February 2019 patch 4.
With either upgrade you will get a version of the REST Connector that works with the NPrinting API
Thank you for info.
In that case I will need to figure out how can I run all 12 tasks within one Qlik Sense App. Can you please help me?
Should I only add extra lines with task ID's into "NP GET Task" and "NP POST Task execution" or is there some other API which allows multiple task run from one API?
Thanks
B.