Skip to main content

Nprinting API: Send On-demand request with Postman

No ratings
cancel
Showing results for 
Search instead for 
Did you mean: 
Damien_Villaret
Support
Support

Nprinting API: Send On-demand request with Postman

Last Update:

Feb 18, 2022 9:48:50 AM

Updated By:

Joseph_Musekura

Created date:

Aug 6, 2017 5:00:45 AM

This article explains how to send a request to Nprinting On-Demand API using Postman.

The information in this article is provided as-is and to be used at own discretion. Depending on tool(s) used, customization(s), and/or other factors ongoing support on the solution below may not be provided by Qlik Support.


Prerequisites:

  • Before proceeding below, check the following article: NPrinting API Setup Requirements
  • Qlik Nprinting Server 17.4 (June 2017) or higher (Qlik Nprinting Engine also needs to be installed. It is not required to install the On-demand QlikView extension)
  • "Enable On-Demand and API report generation" should be enabled on the report.

    Enable on Demand and API report generation.png

  • QlikView Desktop Personal Edition is not supported.

 

Resolution:


First of all, install the Postman Chrome extension. See QRS API using Xrfkey header in Postman for some basic knowledge about how to getting started with Postman.

Authentication

COMMAND URL
GET https://yourservername:4993/api/v1/login/ntlm

Request headers:

Content-Type application/json


GET Headers.png


If it returns code:0 (Status: 200 OK) then it means that the authentication went well.

If it returns code:1 (Status: 401 Unauthorized), then it may be that the Windows user used does not have sufficient rights.

Go to the Nprinting Web Console and make sure that the user exists and is enabled:

Administration Enabled.png

Fetch the report ID to run

We now need to fetch the report ID for the report we want to run.

COMMAND URL
GET https://yourservername:4993/api/v1/reports


Response:

Fetch ID response.png


The report ID in this case is ce4cd669-4040-4b9c-9f20-94541c907f9e.

Send on-demand request

COMMAND URL
POST https://yourservername:4993/api/v1/ondemand/requests 


Request headers:

Content-Type application/json


Request Body:


       "type": "report", 
       "config": { 
        "reportId": "ce4cd669-4040-4b9c-9f20-94541c907f9e", 
         "outputFormat": "HTML" 
       } 


The following response should be returned:

Result Body.png


The request ID is b81a2160-d871-4c09-952c-bd8d28563986 in this case. We can use this ID to check the request status and fetch the request when it is completed.
 
Note: if the POST request returns the error "403 Forbidden REVEL_CSRF: tokens mismatch" check this link  and add the X-XSRF-TOKENwith the value of the cookie in the header

manage cokies.png

Fetch On-demand request status

COMMAND URL
GET https://yourservername:4993/api/v1/ondemand/requests/b81a2160-d871-4c09-952c-bd8d28563986


Response:

 

 

{
    "data": {
        "id": "b81a2160-d871-4c09-952c-bd8d28563986",
        "status": "completed",
        "created": "2017-08-06T08:50:26Z",
        "requestType": "Report",
        "reportType": "Html",
        "outputFormat": "HTML",
        "title": "Report1"
    }
}

 

 


Download Report

You will need to open this URL in a browser tab in order to download the report as Postman will just show the file as binary.

URL:
https://yourservername:4993/api/v1/ondemand/requests/b81a2160-d871-4c09-952c-bd8d28563986/result

A popup will appear and asks if you want to download the file.

Note: If you are not authenticated in the browser you are trying to request this URL from. You will need to log in again using https://yourservername:4993/api/v1/login/ntlm

Labels (1)
Version history
Last update:
‎2022-02-18 09:48 AM
Updated by: