The following only works in specific versions of Qlik Sense and NPrinting. Please check with a Qlik Integrations/Development support engineer with any questions. The Qlik Sense/View Rest connector is required to be manually updated to version 1.3.
Download and extract the appropriate Rest Connector for either QlikView or Qlik Sense v1.3 (will be available with the NPrinting Feb. 2018 release).
Backup the Existing Rest connector file folder
Copy the extracted files to the existing rest connection installation files folder
Reboot the server where the installation files are copied to.
When using Qlik Sense REST connector to connect to NPrinting APIs, the connector may show error “Failed to connect to server” or “HTTP protocol error 403 (Forbidden): The server refused to fulfill the request” , although the same API call works in web browsers or Postman.
According to NPrinting reference page at http://help.qlik.com/en-US/nprinting/June2017/APIs/NP%20API/, API users need to call method GET /login/ntlm to authenticate themselves first. This will create a cookie for subsequent calls in the same session. However, unlike web browsers or API tools like Postman, Qlik Sense REST connector does not save this session cookie automatically for subsequent calls.
A workaround is to manually save the cookie after the first authentication call, then add the cookie as a query header in the REST Connector configuration.The following article presents an example for how this can be achieved:
1. NPrinting API only supports Windows NTLM authentication
In Qlik Sense, when Qlik REST Connector is configured with Windows Authentication, the connector always uses credentials of the Qlik Sense service account. Therefore, the first step is to create an NPrinting user associated with the Qlik Sense service account and grant necessary roles to this user.
2. Create a REST Connector with the following configuration:
In which, the third cookie (highlighted in yellow, without cookie properties Path, HTTP, Secure) is needed for subsequent API calls. This cookie can be extracted from the string using any string manipulation technique in Qlik Sense. For example, the following script extract the cookie into variable vCookie:
let vCookieRaw = Peek('Set-Cookie',0,'_response_header'); let vCookie = TextBetween('$(vCookieRaw)','Secure,','Path=/',2);
(in this example, ‘_response_header’ is the name of the table generated by the REST connector in step 3)
4. The extracted cookie can then be used as a query header in subsequent API calls.
This can be done either by creating a new REST connection, or overriding the current REST connection using WITH CONNECTION keyword.
New REST connection: create a new REST Connector to the API url that needs to be called. Create a query header named “cookie” and paste the cookie string in step (3) as the value
If you don’t want to create another REST connector, you can use WITH CONNECTION keyword to override the URL and query header of the existing connector created in step (2). For example:
FROM "items" FK "__FK_items")
FROM JSON (wrap off) "data" PK "__KEY_data"
HTTPHEADER "cookie" "$(vCookie)"
Please refer to the attached qvf app for an example.