Skip to main content

Qlik Sense Documents

Qlik Sense documentation and resources.

Qlik Cloud Maintenance is scheduled between March 27-30. Visit Qlik Cloud Status page for more details.

Distribute NPrinting reports after reloading a Qlik App

Showing results for 
Search instead for 
Did you mean: 

Distribute NPrinting reports after reloading a Qlik App


***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:


  1. Common Scheduler

    Currently NPrinting and QLik (Sense or View) have separate schedulers.

    If you reload a Qlik application daily at 1:00AM and want to send the NPrinting reports directly after a successful reload, you must schedule them separately for times that you believe  will not intefere with each other.   Its better to have a100% chained solution however whereby reports are only distribute upon successful reload of the Qlik app.

  2. Error handling


     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.




       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  to create the two connections.


Image 1 Get Rest Connection.png


Image 2 Post Rest Connection.png


      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 .

Image 3 Variables.png


                  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)


Image 4 Variables.png


       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)

               Image 5 Task setup.png




            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.


Image 6 Load Script.png


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);
end if


Related information:

Labels (2)

You might be missing 'Allow Response Headers' on the GET connection




Partner - Contributor III
Partner - Contributor III

I am trying this setup with QV + NP environment. (Both in latest version)

After setting up, the result as follow




Error message pop out, after reviewing code, I found some part with syntax error, any idea how to modify?

Btw, i did some extra test, when I quit the script after running the function "fPostTaskExecution", no error pop out, but the NP task is not execute too .


Checked cookie and task ID is retrieving normally, any idea for the root cause?




In this part of the code,  its meant to force an error in the script AFTER the task has been kicked off, but for some reason it didn't complete or time out. Specifcally not "completed", "enqueued", or "running.  I listed the possible status below but basically the expectation is that the publish task execution failed.   

if you go into the NPrinting web console and go to task -> executions, do you see the task executing (or failed, or warning....)

  • WaitingForRetry
  • Enqueued
  • Assigned
  • Running
  • Completed
  • Aborting
  • Aborted
  • Failed
  • Timeout
  • Warning
  • Failing
  • CompletedWithWarning
Partner - Contributor III
Partner - Contributor III

@JonnyPoole , There are no record in Nprinting console.

I also try add "exit script;' after running the function "fPostTaskExecution", no error pop out, but the NP task is not execute too. The QV script is running normally without any error pop out

Listed out some variable result as checking, I think this should be correct.



Partner - Contributor
Partner - Contributor

Hello there,

I'm trying to trigger publish tasks in NPrinting from Qlik Sense using NPrinting API. 

I've read the above article but due to security,  we are not allowed to use NTLM authentication. Our NPrinting is configured to only use 'Qlik NPrinting authentication'.

Will it be possible to achieve a scenario where we use the REST connectors without using NTLM?



@michal_robak   YES its possible to use the NPrinting REST API without NTLM authentication.   You would have to enable JWT authentication in the NP Console using a certificate of your own provisioning.  And then you would need to make sure each API call would be made with an accompanying JWT that matches our specification.

In this scenario, there is no need to call the login/ntlm end point explicitly as NPrinting is designed to 'auto-read' the userID in the JWT and grant you an NP session as that userID.  After the initial API call, the JSON response will include a session cookie which you can use in subsequent API calls to continue using the same session.  The latter is like the qlik script code with NTLM which also grabs a session from the JSON response to login/ntlm.   

The trickiness here is not in provisioning a certificate or configuring NPrinting to enable JWT authentication, the trick is installing/configuring  a separate web service or proxy between the user and the NPrinting Web Engine  that will upgrade an incoming API request with a JWT and forward it to the NPrinting Web Engine.   Installing a custom service has been the favored approach of Qlik Professional services and they've done this in the past with several NPrinting customers as part of a paid engagement.  I think a few Qlik partners have also done this too.   

I know this is not a simple solution but it will work,  NPrinting 100% supports JWT authentication,. In fact QlikView customers who deploy on-demand with IIS automatically use JWT authentication with NPrinting so there are plenty of NP customers that use QlikView (out of box solution) and Qlik Sense (custom solution) with JWT authentication for NPrinting.   In this scenario, it matters not which Qlik Sense authentication provider you use (SAML, OIDC, AD etc...) either.  

Partner - Contributor
Partner - Contributor

Before i start exploring the JWT solution, I'm trying to get POC temporarily using NTLM, and the solution provided in this article. 
I have one issue, every time I try to create POST REST connector (every time I click created), I'm getting this error  "HTTP protocol error 401 (Unauthorized): Requested resource requires authentication."  so I'm trying to do the workaround in the provided article but it does not give me solution how to Create required data connection, only what changes needs to be made in scrip. But before I start making any changes in the loading script how do I create a POST API connector?
Just to add the GET connector works and connect and then I modify it to POST and getting error


Try reviewing this landmark document on the overall approach.   pgs 8-9

Partner - Contributor
Partner - Contributor

I'm reviewing these pages over and over. the GET connector works and connects, then I modify it to POST (following the pages) and get an error.


A few things have to line up around the UserID and the Origin.   Did you configure the allowed origin and set it in the POST?   



Version history
Last update:
‎2021-07-14 12:20 PM
Updated by: