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
framacdev
Contributor III
Contributor III

Hello community,

I am trying to use the guide "How to use Qlik NPrinting APIs inside a Qlik Sense load script".

When the script to get the cookie variable "let vCookie = TextBetween('$(vCookieRaw)','Secure,','Path=/',2);"

the variable is empty.

I am using Qlik Sense February 2019 SR 1.

Can you explain what where I can find the cookie information inside the Set-Cookie field.

Thank you,

Francesco

Frank_S
Support
Support

Hi 

Unfortunately there is a bug with the Qlik Sense Rest connector that comes with Qlik Sense Feb. 2019 that is causing NP API issues.

For updates, please see the following article which will contain updates as they are received from R&D.

Sincerest apologies for the inconvenience while our R&D team works to resolve the issue.

The workaround suggestion is also in the article below.

https://support.qlik.com/articles/000059611

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

Hi ,

Please help us get the Status and Completed data from the NPrinting API. 

REST API : https://host/api/v1/tasks/taskid/executions

1.JPG

QLik Script:

LIB CONNECT TO 'NPrinting REST_POST';


let vPublshTaskURL = 'https://host/api/v1/tasks/'&'$(vTaskId)'&'/executions';

RestNPTaskTriggerTable:
SQL SELECT
"__KEY_data"
FROM JSON (wrap off) "data" PK "__KEY_data"
WITH CONNECTION( URL "$(vPublshTaskURL)", HTTPHEADER "cookie" "$(vCookie)");

[_post_items]:
LOAD [__KEY_data] AS [__KEY_data]
RESIDENT RestNPTaskTriggerTable
WHERE NOT IsNull([__KEY_data]);
DROP TABLE RestNPTaskTriggerTable;

rohitk1609
Master
Master

Hi ,

I followed the article and stuck on first point:

 

NP Login
This section contains the instructions needed to perform an NPinting NTLM login in order to obtain the Session Cookie that we are going to use in all the subsequent calls:
//Connect to NPrinting using the GET REST Connection
LIB CONNECT TO 'NPrinting REST Login (qtsel_gpr)';
//Perform a GET call to NPrinting NTLM login API
RestConnectorMasterTable:
SQL SELECT
"Set-Cookie",
"__KEY__response_header"
FROM JSON "_response_header" PK "__KEY__response_header";
[_response_header]:
LOAD [Set-Cookie] AS [Set-Cookie]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__KEY__response_header]);

 

//Extracts session cookie from the API response
let vCookieRaw = Peek('Set-Cookie',0,'_response_header');
let vCookie = TextBetween('$(vCookieRaw)','Secure,','Path=/',2);

 

My user is administrator in NP and root admin in Qlik Sense and same is service user. I added Qlik Sense URL in NP API trusted host.

The value im vCookieRaw  is

"

NPWEBCONSOLE_SESSION=ce9061882ebdd7f0c47dee41359ddc26bcea4532-%00_TS%3Asession%00%00NPWEBCONSOLE_XSRF-TOKEN%3AlAutI%2FIthh1aa0M%2BgIManj5kuK%2FbIHIfULNPeGiBQM4%3D%00; Path=/; HttpOnly; Secure,NPWEBCONSOLE_SESSION=14b848c65f15fc053fdd50a4dcf787b7a5b45c99-%00NPWEBCONSOLE_XSRF-TOKEN%3AlAutI%2FIthh1aa0M%2BgIManj5kuK%2FbIHIfULNPeGiBQM4%3D%00%00_TS%3Asession%00%00userid%3A1e081ad762cf40d78ba959e8652504d6%00%00userlogin%3A2019-06-24T16%3A38%3A18.3479699Z%00; Path=/; HttpOnly; Secure

"

by which null is getting calculated in vCookie .

 

 

Can you please help me to fix it so I can move forward ?

 

Thanks in advance

Rohit

JonnyPoole
Employee
Employee

There are a couple of versions of the REST Connector that don't set the cookie correctly.  The only solution is to upgrade Qlik Sense and the upgrade will update the REST Connector.  Which version of Qlik Sense are you on ?  Qlik Sense April 2019+ works great but not Qlik Sense Feb 2019. Qlik Sense Nov 2018 also worked.  

rohitk1609
Master
Master

unfortunately, I am using Qlik Sense Feb 2019 and NP Feb 2019 SR1.

 

Thanks,

Rohit 

JonnyPoole
Employee
Employee

You wouldn't have to upgrade NPrinting, but upgrading Qlik Sense would be required to get the fix. 

There is also supposed to be an Qlik Sense February 2019 SR3 coming out in a few weeks. You could wait and check the release notes to see if it will be fixed there too. 

rohitk1609
Master
Master

Thanks Jonny  for your help.

 

 

JonnyPoole
Employee
Employee

Yup its fixed in Feb 2019 Qlik Sense, but you need Feb 2019 Qlik Sense SR4 to be exact.  

Jira issue ID: QVXREST-837