Skip to main content
Announcements
Defect acknowledgement with Nprinting Engine May 2022 SR2, please READ HERE
cancel
Showing results for 
Search instead for 
Did you mean: 
nsm1234567
Creator II
Creator II

Nprinting Post Request to web API in June 2020 - 401 Unauthorized

Hey there,

I'm currently using Qlikview and the REST Api to trigger Nprinting tasks after rebuilds complete.  This was working great until I migrated to Nprinting June 2020.  I initially had the issue with making get requests which I was able to solve by changing my vCookie definition as follows:

Let vCookie = TextBetween('$(vCookieRaw)','SameSite=None,','Path=/',3);

However, when running the POST request to actually execute the task I'm getting the below error.  Is there some special way the cookie needs to be passed for POST tasks?  

QVX_UNEXPECTED_END_OF_DATA: HTTP protocol error 401 (Unauthorized):

Requested resource requires authentication.
RestNPTaskTriggerTable:
SQL SELECT
"__KEY_data"
FROM JSON (wrap off) "data" PK "__KEY_data"
WITH CONNECTION( URL "https://server:4993/api/v1/tasks/f6edca21-a7b6-4c2d-99b9-3f33e85cd1a2/executions", HTTPHEADER "cookie" "NPWEBCONSOLE_SESSION=e07b9480b597e133421c5fadf639eefeff9f3b29-%00userlogin%3A2020-07-09T22%3A25%3A01.4661030Z%00%00NPWEBCONSOLE_XSRF-TOKEN%3A7UnKpJHywEXtFZscrc1hYcb1P7YyHZ8ryGj%2FOxPLkwM%3D%00%00_TS%3Asession%00%00userid%3A3425d8703ccc440584b121cf0bf23b43%00; ")

 

Labels (2)
1 Solution

Accepted Solutions
andregas
Partner - Creator II
Partner - Creator II

An update, I've solved adding exactly the same text insert in origin header of POST as trusted origin in NPrinting. http or https make difference.

View solution in original post

7 Replies
andregas
Partner - Creator II
Partner - Creator II

Hello @nsm1234567, I've got the same error using QV 12.50, REST connector 2.11 and NPrinting June 2020 (Initial release). Have you found any solution?

Thanks

andregas
Partner - Creator II
Partner - Creator II

An update, I've solved adding exactly the same text insert in origin header of POST as trusted origin in NPrinting. http or https make difference.

Frank_S
Support
Support

Please check this following community article:

https://community.qlik.com/t5/Qlik-Support-Documents/Troubleshooting-Common-NPrinting-API-Errors/ta-...

The 401 error is addressed therein.

Kind regards...

Please remember hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
nsm1234567
Creator II
Creator II
Author

Hey there, only saw this now!  Didn't get notified that there were responses to my post, but yes, after a bunch of fiddling eventually discovered that the issue was exactly that:  On Nprinting, I needed to whitelist http://localhost explicitly and on the REST side I needed http://localhost to be the origin.  I can confirm this still works in Nprinting November 2020

nsm1234567
Creator II
Creator II
Author

Hey there, thanks for the response.  I don't think this exact error is covered or is perhaps just not super clear.  The issue here was that in previous documentation I'd seen online for the API you could do something like, "origin=localhost" in the post call and then have http://localhost in the whitelisted origins on Nprinting side, which worked until June 2020.  After the upgrade, you had to use "origin=http://localhost" i.e. it had to include the "http" piece.

Frank_S
Support
Support

@nsm1234567 

If you are having issues after upgrading recently, please check the following article as there have been problems with the Qlik Sense rest connector that have been resolved as well as changes to the the load script that are necessary in conjunction with the fixes.

Kind regards...

Please remember hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Frank_S
Support
Support

Please feel free to check the load script in the attached QVF to check against your own work.

This QVF  load script (data included with export) allows:

  • 1. Reload connections in the 'API Testing' App
  • 2. Execute Publish Tasks associated with the 'API Testing' App

It was also not working for me as well after a recent upgrade. The issue was resolved after performing the steps in the article mentioned above and upgrading Qlik Sense to Sept. 2020 Patch 2.

I would avoid using 'localhost' and use the actual server name in the load script.

Please remember hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!