*Notice: Qlik Sense April 2019 release contains the required rest connector v2.11 which resolves a previous software defect affecting versions after 1.3 and up to 2.10
*Note: The Qlik Rest connectors are not supported for use where kerberos authentication is present. See details here: Feature Request: Qlik REST connector should be able to support connections to server with Kerberos authentication(-The following only works in specific versions of Qlik Sense and NPrinting. Please check with a Qlik Integrations/Development TSE with any questions.)
- The Qlik Sense/View Rest connector is required to be manually updated to version 1.3.
1. Download and extract the appropriate Rest Connector for either QlikView or Qlik Sense v1.3 (will be available with the NPrinting Feb. 2018 release).
2. Backup the Existing Rest connector file folder
3. Copy the extracted files to the existing rest connection installation files folder
4. 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 work-around 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 (http://help.qlik.com/en-US/nprinting/November2017/Content/Extending/Intro-Extending.htm). 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:
Open the Select data dialog of the newly created REST connector. Check option “Include HTTP response header”
and select response field “Set-Cookie”. Insert the generated script to the app.
Field “Set-Cookie” contains 3 cookies returned by NPrinting Server as a single string when GET /login/ntlm is called. The string should look like the following:
NPWEBCONSOLE_XSRF-TOKEN=V2pQHt7kUuzI4A+oe28rbyVgIyXMY8gyCdKupWjslng=; Path=/; Secure,
NPWEBCONSOLE_SESSION=86e4bf552e79e4c1d0acf898a1d8e1fe10029cc4-%00NPWEBCONSOLE_XSRF-TOKEN%3AV2pQHt7kUuzI4A%2Boe28rbyVgIyXMY8gyCdKupWjslng%3D%00%00_TS%3Asession%00; Path=/; HttpOnly; Secure,
NPWEBCONSOLE_SESSION=02cf571338171b5f04195cb4c02ca95cf7ee60d6-%00NPWEBCONSOLE_XSRF-TOKEN%3AV2pQHt7kUuzI4A%2Boe28rbyVgIyXMY8gyCdKupWjslng%3D%00%00_TS%3Asession%00%00userid%3A0d1021800b6f4ea78c478bef82a3c6f2%00; Path=/; HttpOnly; Secure
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.