Skip to main content
Announcements
Defect acknowledgement with Nprinting Engine May 2022 SR2, please READ HERE
cancel
Showing results for 
Search instead for 
Did you mean: 
Gianluca_Perin
Employee
Employee

How to use Qlik NPrinting APIs inside a Qlik Sense load script

Hi all,

attached you'll find a step by step tutorial explaining how to use Qlik Sense (and also QlikView) load script to interact with the Qlik NPrinting APIs.

The examples include:

  • Logging in into NPrinting
  • Collecting data from NPrinting
  • Reloading metadata for a NPrinting connection
  • Create, update and delete NPrinting users
  • Triggering a NPrinting publish task

This document also shows how to use Qlik Sense Tasks to chain these different events directly from QMC.

This tutorial uses standard Qlik REST Connector.

Please read carefully the requirements before to dig into the actual examples.

Enjoy!

58 Replies
DavidFoster1
Specialist
Specialist

@Daniel Jenkins Can you publish a working qlikview example?

steverosebrook
Contributor III
Contributor III

Is there a Word document that exists with all this code in it?  Either that or a QVF that could be shared?  I'd like to try this out, but I can't copy and paste the load script code from the pdf.

Thanks,

Steve

JonnyPoole
Former Employee
Former Employee

i've posted QV and QS samples here  Distribute NPrinting reports after reloading a Qlik App

anindya_manna
Creator II
Creator II

Otherwise below error comes
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.

This tip missed in pages 8/9
anindya_manna
Creator II
Creator II

Hi,

I was able to trigger task in Nprinting through Qliksense API as per this post.Butfrom today I am getting an error which I don't have any clue.If anyone faced this type of issue please help me on this.Please find below error msg and attached log.

Error messageError message

anindya_manna
Creator II
Creator II

This is authentication error.Make sure that you put domain,username and pwd correctly.Sometimes qliksense domain name is different from windows domain.

Frank_S
Support
Support

Check the following support article.

NPrinting API Error: QVX_UNEXPECTED_END_OF_DATA: HTTP protocol error 500 (Internal Server Error)

https://qliksupport.force.com/articles/000057354

You need to log into the support site to down load relevant attachments.

Please remember hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
anindya_manna
Creator II
Creator II

Thanks!! It helps to solve my problem.
anindya_manna
Creator II
Creator II

Solution below-
NPrinting API Error: QVX_UNEXPECTED_END_OF_DATA: HTTP protocol error 500 (Internal Server Error):

Description
What are you attempting to do?
When attempting to trigger NPrinting Tasks using the NPrinting API Task Trigger from a reloaded QlikView application the QVX-UNEXPECTED-END-OF-DATA-HTTP-protocol-error-500-Internal-Server-Error error is generated
What is the expected result?
If a publish task is disabled, the API should be able to manage disabled published tasks

APP TASK
PROD Publish Task 1
PROD Publish Task 2

What is the actual result?
If any of the NPrinting Publish Tasks are initially enabled as above but then subsequently disabled or deleted, the following reload error occurs:
QVX_UNEXPECTED_END_OF_DATA: HTTP protocol error 500 (Internal Server Error)
Cause
Cause:
The current NP TASK API, is unable to manage disabled NPrinting Publish Tasks that were previously enabled.
If any Publish Task is disabled that was previously enabled, the error QVX-UNEXPECTED-END-OF-DATA-HTTP-protocol-error-500-Internal-Server-Error will be generated when reloading your application.

An improvement has been submitted that is expected to:
prevent any disabled tasks in the app from causing the reload error 'QVX_UNEXPECTED_END_OF_DATA: HTTP protocol error 500 (Internal Server Error)"
Resolution
Solution : Multiple Publish Tasks within a Single NP 'App'
Keep all Publish Tasks enabled within the NP App as in the example above. Do not disable or delete any of the Publish Tasks.
NOTE: If you must disable a publish task, you can simply disable the report or remove the report and recipients from the task but do not disable the task itself.

NOTE: that processing of more than a single tasks not a bug but rather a problem with code used to execute tasks
The API is expected to be updated in a future release of NPrinting to better manage previously enabled but then subsequently disabled tasks in an NP 'App'
At the moment, we cannot provide an estimate at this time when the update will be included in the NPrinting API library as the scope of work and implementation of the improvement is currently underway by our R&D team. The workaround is to keep all tasks enabled or follow the note in solution 2 if a report in a task must no longer go out.
In order to allow multiple tasks to run, update your load script with the appropriate code available in the QVW load script attached to this article.

UPDATE: New code has been provided by R&D that is attached to this article.This code will allow you to execute all publish tasks in within a single NPrinting App.
Caveate: You must have at least 1 publish task enabled.

Conclusion: There is no bug with the API. If you get the error QVX_UNEXPECTED_END_OF_DATA: HTTP protocol error 500 (Internal Server Error)" this is a warning that there is a problem with the code you are using in conjunction with the NPrinting Task Execution API. Use the attached code which includes the NPrinting Task Execution API to resolve the error.
Disclaimer
Access to this article is provided to you as part of your subscription to Qlik Maintenance. This article is deemed to be “Documentation” under the terms of the license agreement applicable to your Qlik software. All rights reserved © QlikTech International AB.
anindya_manna
Creator II
Creator II

Hello Experts,

From the above post I am able to trigger Nprinting task through Qliksense API.Now I am trying to create a dashboard to show all the task details along with execution status of the task whether running or completed or enqueue. I got a metadata table from which I can fetch all the task details time of creation,last execution etc but unable to get execution status.The below code will fetch all the task details.

Is there any other metadata table from where I can get execution status of all task? I can fetch individually execution status of a task but need the entire list.

LIB CONNECT TO  $(vAPIConnectionNameForGET);
//exit script;

let vEndpoint=  vNPrintingServer  & '/api/v1/tasks' ;

    RestConnectorMasterTable:
    SQL SELECT 
        "__KEY_data",
        (SELECT 
            "id",
            "name",
            "description",
            "type",
            "created",
            "lastUpdate",
            "lastExecution",
            "enabled",
            "appId",
            "__FK_items"
        FROM "items" FK "__FK_items")
    FROM JSON (wrap off) "data" PK "__KEY_data"
    with Connection (URL "$(vEndpoint)", HTTPHEADER "Cookie" "$(vCookie)");

    [items]:
    LOAD	[id] AS [id],
        [name] AS [name],
        [description] AS [description],
        [type] AS [type],
        [created] AS [created],
        [lastUpdate] AS [lastUpdate],
        [lastExecution] AS [lastExecution],
        [enabled] AS [enabled],
        [appId] AS [appId]
    RESIDENT RestConnectorMasterTable
    //WHERE NOT IsNull([__FK_items]) and [name]= $(vNPrintingPublishTaskName);
    WHERE NOT IsNull([__FK_items]); // and [id]= '$(vNPrintingPublishTaskID)';