The NPrinting API for Noobs
It started with a question: Can we trigger an NPrinting task to publish reports right after data reload is successfully performed by Qlik Sense or QlikView?
Join the DZone community and get the full member experience.
Join For FreeNPrinting is important for many users. In the 2017 June release, on-demand reporting is enabled with the NPrinting API. Immediately after the release, the above question was raised to me. I spent a few days trying to prototype a solution but ended up with something that is so simple that anyone can do it in 10 minutes. Frustrating? Yes, because I spent so much time on something that is just a little bit better than “Hello, World!” On the other hand, simple is awesome; simple means even a non-technical user can implement it without problem. Pretty cool.
With that, I’m sharing my experience in case I can help others stuck with a similar problem.
Long story short, it is implemented with a single HTML file, not even a server is required.
1. Create an HTML file and paste this code into it.
2. Modify the task IDs.
3. Modify the API endpoint URI.
4. Now open the HTML file via a browser (I used Chrome). You should then be able to see your browser pop-up and close immediately after that.
5. That’s it, you’re done! Now you should see the task running in the NPrinting web console.
But how can you automate this process, you ask?
1. In Qlik Sense or QlikView, call a batch file to open your HTML file with Chrome:
start chrome “C:\Users\…your directory…..\nprintingApiTest.html”
Things to Note
1. The Qlik NPrinting API is stated as experimental, which means it may be modified in future. This solution is based on 2017 June released.
2. How to find the task ID:
3. HTTPS vs. HTTP:
It took me hours to realize that it is HTTP in the documentation, but my actual server is HTTPS. I hope I am the only stupid one here, but wanted to note it.
4. About the NTLM login:
The user is prohibited from doing anything without a login for NPrinting and NTLM is the only login mechanism supported via the API (for now). So, before you implement anything, you should have a rough understanding of NTLM.
When you open the NPrinting web console/news stand, you will see the following login page. Here you have two options: Windows login or email and password login. The Windows login is the NTLM login.
NTLM takes your Windows credentials to login into another system.
In the NPrinting user console, there is an entry for the domain account. This is for enabling Windows login. If it doesn’t work, check the direction of the slash as shown below.
How to get the domain and username in cmd:
Take note that the domain username pair is tagged to your NPrinting user.
Also, sessions are handled by the browser. If you close your browser, the login state will be lost and you must re-login.
Keeping a session alive is particularly challenging with other technology. There are several NTLM libraries for Python and Node but I didn’t have luck with them. Let me know if you have any questions. And definitely let me know if you get it to work.
Cheers and happy hacking!
Published at DZone with permission of Wuzhong Zhu, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments