Getting started

The Qlik NPrinting API is a REST API that you use to manage your Qlik NPrinting objects programmatically. A subset of the functionality that you find in the Qlik NPrinting Web Console is available through the API.

The objects you manipulate in the Qlik NPrinting Web Console are represented in the API as JSON entities. These entities have properties that correspond to the settings you find in the Qlik NPrinting Web Console. The API has a set of endpoints that allow you to create, retrieve, update, and delete entities for apps, users, groups, reports, and so on. For all requests, the data returned is filtered based on user permissions, that is, if a user is not authorized to access a certain entity, that entity is not returned in the response.

A user must have an associated domain account to log into the API as an authenticated Windows user. For more information about configuring a domain account, see Creating users.

To help familiarize you with the API, we will walk through some simple examples using a REST client called Postman. You will learn how to:

  • Connect and authenticate your user credentials
  • Retrieve a list of apps
  • Update an entity
  • Create a filter

Before you start, you will need to:

Note: Depending on your environment, you may need to configure Chrome to accept self-signed certificates. See the Chrome documentation for additional information and instructions.

Connecting to Qlik NPrinting APIs

By default, Qlik NPrinting Server listens for REST requests on port 4993, so the URL is:

https://NPrinting.server.name:4993/api/v1/<path>

Authenticating your user credentials

Before you do anything with the NPrinting API, you must authenticate your user credentials.

In the example that follows, we will authenticate with the current Windows user name.

Open Postman and fill in the fields as shown below, replacing NPrinting.server.name with the URL of the computer where your Qlik NPrinting Server is installed:

Retrieving a list of apps

The following endpoint returns a complete list of Qlik NPrinting apps that the current user has permission to see.

Open Postman and fill in the fields as shown below, replacing NPrinting.server.name with the URL of the computer where your Qlik NPrinting Server is installed:

The response includes the ID, title, and other details about each app.

Updating an entity

You can update certain entities through the API by using the PUT method. When you update an entity, Qlik NPrinting Server may substitute default values for omitted properties, so we recommend that you always include the entire entity when you perform an update.

In this example, we will update the email property of the users entity.

To update the entity:

  1. If you do not know the ID of the user you want to update, enter the following path in Postman and send a GET request:

     /users

    Search for the user ID in the response.

  2. Append the user ID to the users path in Postman and send a GET request:

    /users/{id}

    The response should look something like this:

    { "data": { "id": "113ac265-163e-4feb-854e-ade3cdafc837", "email": "abc@example.com", "created": "2018-02-22T16:17:18Z", "lastUpdate": "2018-02-28T18:20:57Z", "enabled": true, "userName": "Test", "domainAccount": "domain\\test", "timezone": "Europe/Rome", "locale": "En", "folder": "test folder", "subFolder": "test subFolder" }

    }
  3. Copy the content surrounded by the inner parentheses from the returned entity and paste it into the body of a new PUT request.
  4. Change the value of email.
  5. Add the password property and corresponding value to the entity. The body of the request should look something like this:

    {
        "password": "test",
        "id": "113ac265-163e-4feb-854e-ade3cdafc837",
        "email": "xyz@example.com",
        "created": "2018-02-22T16:17:18Z",
        "lastUpdate": "2018-02-28T18:20:57Z",
        "enabled": true,
        "userName": "Test",
        "domainAccount": "domain\\test",
        "timezone": "Europe/Rome",
        "locale": "En",
        "folder": "test folder",
        "subFolder": "test subFolder"
    }

  6. With the updated entity in the body, send a PUT request using the following path:

    users/{id}

    In this example, {id} would be 113ac265-163e-4feb-854e-ade3cdafc837.

  7. Send a GET request using the same path to verify the change.

Creating a filter

You can create filters for tasks, reports, users, and objects through the API by using the POST method. In this example, we create a simple filter for CategoryName, which is a field in the data source of a sales application.

  1. To create a filter, you need to know the IDs of the app and connection that you want to apply the filter to.

    To retrieve the IDs, send a GET request using Postman to each of the following paths:

    /apps

    /connections

    For example, to get the app ID, send a GET request to NPrinting.server.name:4993/api/v1/apps.

    Search for the IDs in the responses.

  2. Here is an example of the code that includes the app and connection IDs in the body of a POST /filters request:

    { "appId": "de867383-3d6a-4f37-8fe5-387552c60d3f", "enabled": true, "name": "AverageSaleByCategory", "description": null, "fields": [ { "connectionId": "9a7b1016-8d22-46ac-a384-158f715547a7", "name": "CategoryName", "overrideValues": false, "values": [ { "value": "Bath Clothes", "type": "text" }, { "value": "Men´s Clothes", "type": "text" }] }] }

    The response includes the ID of the newly created filter, which is returned in the location header.

What to do next

Now that you have seen some requests in the Qlik NPrinting API, try some of the other API endpoints, for example, to start a new task execution.

Here are some additional resources that can help you: