Qlik Community

Qlik Support Documents

Documents related to Qlik Support.

NPrinting API script Example - Python

Employee
Employee

NPrinting API script Example - Python

As for any operations made via user interface also the APIs require authentication before allowing anyone to deal with them. Few realize how to deal with the authentication phase before calling an API end-point, here a short example on how to authenticate against NPrinting before made any API call, using python.

The example attaches attempt a call to the start a task, but any and-point can be made using the same logic.

Before start, we need to download the NPrinting Certificate from the browser. One connected to the NPrinting, Browser warning us about the self-signed certificate. You should be able to download it and locate near the script.

Let's start with the required imports

import sys

import requests

import json

from requests_ntlm import HttpNtlmAuth

Then we need to replace a number of variables used the deal with the endpoints (rows 6 to 13)

The actual authentication phase needs to be called just once, in the example function Auth(). If the authentication succeeds, the response contains a cookie called  NPWEBCONSOLE_XSRF-TOKEN. All subsequent calls need to echo the same cookie and set an header variable called  X-XSRF-TOKEN with the same value.

Version history
Revision #:
1 of 1
Last update:
‎09-18-2017 04:16 AM
Updated by:
Employee