Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
steverosebrook
Contributor III
Contributor III

NPrinting APIs No Longer Working After Upgrading to NPrinting Nov 2019

We just upgraded our NPrinting instance to the November 2019 version (SR1).  (Our Qlik version is also Nov 2019 - Patch 6.)  We had been using NPrinting REST connections successfully prior to this upgrade to run NPrinting tasks using Qlik Sense load script.  Now, when we try to test the NPrinting Get and Post API connections, we're getting a 401 error: "HTTP protocol error 401 (Unauthorized): Requested resource requires authentication."

We have verified every aspect of the connection settings: we're using Windows NTLM, using an NPrinting user that was created based on the Qlik service account, etc.  Like I said, all of this was working prior to the upgrade, but now it isn't.

I've tested the URL we're using with a Chrome browser - and the URL is returning information successfully via Chrome.  But not with Qlik.

We're out of ideas - and I'm not finding any posts out there with similar issues.  So any help from the Community would be much appreciated.

Thanks!
Steve

Labels (2)
1 Solution

Accepted Solutions
steverosebrook
Contributor III
Contributor III
Author

So I figured this out.  Here's the code you need to use:

let vNPCookieRaw = Peek('Set-Cookie',0,'_response_header');
let vNPCookie = TextBetween('$(vNPCookieRaw)','SameSite=None,','Path=/',2);

View solution in original post

7 Replies
steverosebrook
Contributor III
Contributor III
Author

After some research, I'm realizing that the cookie returned from NPrinting has changed in the November 2019 version.  The cookie information returned from NPrinting used to look like this (the red portion is what we parsed out as the final cookie to send back to NPrinting):

NPWEBCONSOLE_XSRF-TOKEN=a3jv9maV/ApzN/59isZXcH2DqMjRHdq+fJKe6Z6s3wE=; Path=/; Secure,NPWEBCONSOLE_SESSION=7f6c7fe9655c77a31b73e7a4be3edac9833ddda6-%00NPWEBCONSOLE_XSRF-TOKEN%3Aa3jv9maV%2FApzN%2F59isZXcH2DqMjRHdq%2BfJKe6Z6s3wE%3D%00%00_TS%3Asession%00; Path=/; HttpOnly; Secure,NPWEBCONSOLE_SESSION=68d3fb19d37412f518f8be7e61f47d8073228448-%00_TS%3Asession%00%00userid%3Af00ec7ac86bf46e481bfa02d809a9977%00%00userlogin%3A2020-03-27T18%3A15%3A02.5981740Z%00%00NPWEBCONSOLE_XSRF-TOKEN%3Aa3jv9maV%2FApzN%2F59isZXcH2DqMjRHdq%2BfJKe6Z6s3wE%3D%00; Path=/; HttpOnly; Secure

However, now the cookie information looks like this:

NPWEBCONSOLE_XSRF-TOKEN=FDJIyaUWDtIQ8Ajiw4/KLwvhXpsE4wf2VhBANs6dwmA=; Path=/; Secure; SameSite=None,NPWEBCONSOLE_SESSION=13a27f6ece749022906de6dc81fe3303e34be70e-%00NPWEBCONSOLE_XSRF-TOKEN%3AFDJIyaUWDtIQ8Ajiw4%2FKLwvhXpsE4wf2VhBANs6dwmA%3D%00%00_TS%3Asession%00; Path=/; HttpOnly; Secure; SameSite=None,NPWEBCONSOLE_SESSION=c51a57ebb6d6430c387b378b68def094e3b1f813-%00_TS%3Asession%00%00userid%3Aad3f1e18086040a39f6b094fde386016%00%00userlogin%3A2020-03-27T18%3A17%3A51.1993157Z%00%00NPWEBCONSOLE_XSRF-TOKEN%3AFDJIyaUWDtIQ8Ajiw4%2FKLwvhXpsE4wf2VhBANs6dwmA%3D%00; Path=/; HttpOnly; Secure; SameSite=None

There's now a semicolon after the word "Secure", and the phrase "SameSite=None".  I'm trying to figure out what text I need to parse out to be able to send back to NPrinting to make an API post call to run a task.   Nothing is working for me so far.

Anyone know how this works now?

steverosebrook
Contributor III
Contributor III
Author

I guess bottom line, here's what I need to know.  Prior to our upgrade to Qlik and NPrinting Nov 2019 versions, here's the code we were using to create the cookie to send back to NPrinting:

let vCookieRaw = Peek('Set-Cookie',0,'_response_header');
let vCookie = TextBetween('$(vCookieRaw)','Secure,','Path=/',2);

That code no longer works.  Does anyone know what the new code is for creating vCookie?

steverosebrook
Contributor III
Contributor III
Author

So I figured this out.  Here's the code you need to use:

let vNPCookieRaw = Peek('Set-Cookie',0,'_response_header');
let vNPCookie = TextBetween('$(vNPCookieRaw)','SameSite=None,','Path=/',2);

Rohan
Specialist
Specialist

Dear All, 

We are facing same issue after upgrade from Dec 19 to May 2023. We have changed the Cookie variable appropriately, but still we are getting the same unauthorized 401 error.  

Any Help would be appriciated.

@Sonja_Bauernfeind @sunny_talwar @hic @Daniele_Purrone @Chip_Matejowsky 

Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi @Rohan, Where are you triggering your request from Qlik Sense or QlikView? It is possible you have upgraded also Qlik Sense and you are experiencing Qlik Sense Rest connector issue? 

https://community.qlik.com/t5/Official-Support-Articles/Qlik-Sense-May-2023-Patch-3-causes-REST-conn...

Below is part of the code from NPrinting.qvs file I have created few years ago which works with current versions as well: https://nprintingadventures.com/2019/04/08/nprinting-api-qlik-rest-subroutines/

cheers

 

//	Extracts session cookie from the API response

            Let vCookieRaw 	= Peek('Set-Cookie',0,'cookie_items');
            // Cookie version
            If $(vNPVersion) < 20200201 Then
                Trace Loading cookie based on NPrinting version prior Feb 2020 SR1 release;
                Let vCookie 	= TextBetween('$(vCookieRaw)','Secure,','Path=/',2);
            ElseIf $(vNPVersion) < 20200401 Then
                Trace Loading cookie based on NPrinting version equal or post Feb 2020 SR1 release;
                Let vCookie 	= TextBetween('$(vCookieRaw)','SameSite=None,','Path=/',2);
            Else
                Trace Loading cookie based on NPrinting version equal or post Seb 2020 Initial release;
                Let vCookie 	= TextBetween('$(vCookieRaw)','SameSite=None,','Path=/',3);    
            EndIf
            ;

 

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.
Rohan
Specialist
Specialist

Hi @Lech_Miszkiewicz , We had Qlik Sense Enterprise Feb 2022 Patch 9 working with Nprinting 19. We finally we able to upgrade Nprinting to May 2023. We have already handled the cookie part, but still we are unable to make the post connection, Get connection is working fine. Also in the code we had for trigger, there was a comment regarding whitelisting the source ips on Nprinting Server post September 2020 or something, currently we are checking this lead with Network team.

Thanks for your reply. Will update here, if we figure out anything.

 

Regards,

Rohan.

Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

Those things wouldn't change after upgrade. I have set it up multiple times with many versions and never had issue so if it worked before for you there is no network component you need to worry about. It is all about your connections and potentially REST connector. The error you would  get when reloading app and triggering POST connection would indicate what possibly is wrong. 

cheers

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.