NPrinting API – Qlik Rest SubRoutines

Hi everyone!

This is going to be a short post, but I put a lot of effort and time to prepare it. It will circle around Qlik NPrinting API and already well described here by Gianluca method of using Qlik RESTfull connector to send requests to NPrinting API from QlikView or Qlik Sense script. Please read his document well and also go through his post and questions from users to troubleshoot connection issues, authentication etc.

So, I have spent few weeks trying to go through NPrinting API methods and put as many of them as possible in Qlik script subroutines. Attached here is NPrinting.qvs file which contains ready to use Subroutines.

This QVS files contains 3 sections:

  • SETUP & SETTINGS – this is configuration section which you need to configure in order to get everything working. In setup section I have provided configurations of GET and POST RESTfull connections. SETTINGS section uses variable to configure hostnames of Qlik Sense/QlikView, Qlik NPrinting, Library/Path connections etc.
  • TASK section contains individual methods
  • JOB section contains samples of jobs which you can easily create using procedures from TASKS
I use Visual Studio Code as an editor which allows me to nicely collapse sections of each method and have a full overview of the script

Let’s have a look at how we can use it.

We need to load NPrinting.qvs file using Include (I always use Must_Include to make sure that I do not skip any code). This will get all subroutines available for us to call. In the JOB SETS section i created job sample(s) which combine individual tasks into logical path. For example this one:

NP_JOB_Reload_N_Publish sub combines following subs:

  • authenticates and captures session cookie
  • gets AppId based on vNPrintingAppName parameter – this is a NPrinting app name which will be used in subsequent steps
  • gets all ConnectionsId(s) with optional connection name parameter (if not specified it loops through all connections from in AppId. Reloads metadata of those connection. There is additional parameter (metadata reload timeout which allows to stop it if it runs for longer than specified time)
  • Gets all Publish Tasks (based on vNPrintingTaskName) which can be:
    • empty – all tasks
    • comma separated: list of tasks to trigger
    • task name – single task to trigger
  • Triggers above mentioned task(s) and waits for them to finish publishing.

This all can be handled in QlikView or Qlik Sense using 2 lines of script code:

In line 21 I include qvs file.

In line 23 i call “job NP_JOB_Reload_N_PublishTask” to:

  • go to NPrinting Application called ‘Testing’,
  • check and reload all Connections in this App (note: ” in parameter string)
  • if metadata reload goes longer than 10 minutes then abort (note 10 as last parameter)
  • publish “testing” and “testing12” tasks.

This is just a sample of what can be done. QVS file contains Sub(s) allowing you to delete users, import users from table loaded into Qlik, create or update users groups, filters, roles. User imports are based on XLS templates from Qlik Help site, but can also come directly from any other table which will have suitable fields. This is still work in progress and the whole purpose of it is to show that you can create quite flexible tool according to your needs and you can move entire scheduling and NPrinting distribution entirely to QMC.

QVS file contains my approach, but you can use it as an inspiration to write your own script, modify mine to suite you better and explore NPrinting API more. You can see in my examples how to change POST method to PUT, PATCH or DELETE.

Depending on your needs you can create jobs directly in Qlik Script or call all required tasks independently. It is all up to you.


  1. Hi Lech – great to see the REST Connector techniques organized and managed using reusable scripting best practices.
    i’d recommend upping the limits on the GET requests to ensure you get more than the default 50 entries returned by the API.

    QUERY “Limit” “1000000”

    WITH CONNECTION( URL “$(vEndpoint)”, HTTPHEADER “Cookie” “$(vCookie)” ,QUERY “Limit” “1000000”);


  2. Amazing work. Thank you for sharing this

    Do know you if it is possible (maybe using another method) to create a new nprinting publishing task and configure it ?



      1. Hi Lech,
        Thanks for your reply.
        I just want to get connection metadata last reload(Last cache update) details.
        Could you please help me on that.


      2. So yeah – like i said in my previous comment – you can use the method described in the link.

        That method is not implemented in the NPrinting.qvs file but you can simply use “Get Connection” and then run script which will look similar to this:


        SQL SELECT
        FROM JSON (wrap off) “data”;

        LOAD [id],
        ConvertToLocalTime([lastUpdate],’Sydney’) as LastUpdateLocal,
        RESIDENT RestConnectorMasterTable;

        DROP TABLE RestConnectorMasterTable;


  3. Hi Lech,

    Many thanks for your reply.
    The link -https://“YourNPrinitngServer”:4993/api/v1/connections/”YourConnectionId” is giving the connection Last update not “LAST CACHE UPDATE”.
    I have reloaded connection meta data few minutes before and the same date and time is appearing against in “Last cache update” column in NPrinting URL.
    BUT the same data and time is appearing the API output.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s