Qlik Community

Ask a Question

Qlik NPrinting Discussions

Discussion Board for collaboration on Qlik NPrinting.

Announcements
Join us at the Cloud Data and Analytics Tour! REGISTER TODAY
cancel
Showing results for 
Search instead for 
Did you mean: 
kalarro
Partner
Partner

Connecting to the API using REST connector

Hi,

I'm getting 401 unauthorized access every time I try to connect to the API on QV 12.20 using the rest connector. NP2.png

 

I have followed every PDF and link that I have found (and there's quite a lot) and done everything needed as far as I can tell. 

I am using QV12.20 desktop and server, NP nov-18, rest connector 1.3 (and 1.75, tried both), on a windows server 2016. Everything in the same machine.

Everything is well connected, I can launch NP tasks that use QV server documents, and I was even able to use the API from an html to launch a NP task (on chrome, same html doesnt work on explorer). But the rest connector fails to connect with 401 error code. 

This is how I configure it:NP1.png

 

You will see it is http and not https, I also tried with https, but trying to fix this error I switched to http (doing everything necessary on nprinting, which is working on http now:NP5.png

 

 

The NPRINTING user with administrator role is correct, and I can use the windows login for nprinting with it:NP4.png

 And I tried with a lot of trusted origins along all my tests:NP3.png

 

I have followed several guides and everything is the same, so I have no idea why it isnt working. Using postmaster, I also get 401 unauthorized, but I dont know how to use that program very well, so maybe Im doing something wrong there.

Like I said, with an html and the following code, it's working (on chrome, not IE):

(function(){
                console.log("started")
                var taskIDs=[
                    "1588aa16-3138-4fdc-96a7-70e84657a5f7",
                ]
                $.ajax({
                        url: 'http://QLIKVIEW01:4993/api/v1/login/ntlm',
                        xhrFields: {
                            withCredentials: true
                        }
                    }).done(function(data) {
                        console.log(data);
                        
                        for(var i=0;i<taskIDs.length;i++){
                            $.ajax({
                                type: "POST",
                                url: 'http://QLIKVIEW01:4993/api/v1/tasks/'+taskIDs[i]+'/executions',
                                xhrFields: {
                                    withCredentials: true
                                }
                            }).done(function(data) {
                                console.log("task "+i);
                                console.log(data);
				<!-- if(i==taskIDs.length) -->
					<!-- open(location, '_self').close(); -->
                            });
                        }
                    });
            })();

But everything I try on the REST connector, fails to authenticate.

Well, if I put the URL: 

http://QLIKVIEW01:4993

It connects, but doesnt authenticate me so I cant do anything after that. And if I add the 

/api/v1/login/ntlm

I get the 401 error. 

Any help would be appreciated, thanks.

On a side note, does rest connector 1.3 work with QV11.20?

 

 

 

Labels (1)
1 Solution

Accepted Solutions
kalarro
Partner
Partner
Author

I just managed to solve it. 

I created a new user account and didnt use any special characters on the password. The previous one was using a . (dot)

With the new user, it is working. 

It is strange, since windows server encourages the use of special characters on the password, yet the rest connection to NPrinting fails with unauthorized error, without any further explanation.

View solution in original post

5 Replies
Frank_S
Support
Support

Hi,

I'm not exactly sure what is causing this issue.

I have tested your scenario without a QV server and it worked for me while using a local NP connection to the QVW that needs to be either reloaded in NPrinting or a task that needs to be executed in NPrinting.

So to that end, I am attached my QVW containing load script that is working. Note that this code is currently set up to execute all tasks in the QVWS app.

You will need to replace QVWS with the name of your App.

Also the code is set up to execute all tasks (and connections...currently commented out of the attached code) in the QVWS app (not individual tasks and connections).

You will also need to:

1. replace your NP server name with the one that is in the code of course

2. you will need to comment out my rest connector connection string and use your own. You should also comment out anything else you don't need.

Finally, you will find the connector compatibility matrix found as a link within the following article: https://support-cdn.qlik.com/articles/000059611

Note: that QV 11.2 does not support the use of Rest Conn 1.3 as per the rest connector compatibility matrix

Hope this helps to get things working for you.

 

We are just 'like' you and like to be liked when providing a helpful answer. You may also press the 'Solution Accepted' button if an answer provided resolves your question or issue... Cheers!
kalarro
Partner
Partner
Author

Thanks a lot for your time.

The problem is this:

2. you will need to comment out my rest connector connection string and use your own.

That's exactly the point that isn't working for me. I can't close the popup windows of the Rest Connector that creates the string, because it says: 

HTTP protocol error 401 (Unauthorized)

But the user and password I use are working on the NPrinting console.

 

kalarro
Partner
Partner
Author

I just managed to solve it. 

I created a new user account and didnt use any special characters on the password. The previous one was using a . (dot)

With the new user, it is working. 

It is strange, since windows server encourages the use of special characters on the password, yet the rest connection to NPrinting fails with unauthorized error, without any further explanation.

View solution in original post

Senor_Dai
Partner
Partner

Hi @Frank_S , Im trying to use your solution to authenticate and obtain a cookie.  Im getting the following value in vCookieRaw :

NPWEBCONSOLE_XSRF-TOKEN=wRyvZ2qjtGcI6tGXNd90mYU6rPDI18nsw8AhEB40uCk=; Path=/; Secure; SameSite=None,NPWEBCONSOLE_SESSION=65341eebe9eb381e18c1e6c879069e73badb3f44-%00NPWEBCONSOLE_XSRF-TOKEN%3AwRyvZ2qjtGcI6tGXNd90mYU6rPDI18nsw8AhEB40uCk%3D%00%00_TS%3Asession%00; Path=/; HttpOnly; Secure; SameSite=None,NPWEBCONSOLE_XSRF-TOKEN=LT2/MZA7JvmXD6lyUK1+Wrv0pFjzHvrig0YjezJ7IVA=; Path=/; Secure; SameSite=None,NPWEBCONSOLE_SESSION=e18cf65f61f7e65d9e5508264b087a0066ffa7a3-%00NPWEBCONSOLE_XSRF-TOKEN%3ALT2%2FMZA7JvmXD6lyUK1%2BWrv0pFjzHvrig0YjezJ7IVA%3D%00%00_TS%3Asession%00%00userid%3A0af4f1283276452c8a33f385dccd8e5f%00%00userlogin%3A2021-02-10T16%3A55%3A22.6487917Z%00; Path=/; HttpOnly; Secure; SameSite=None 

However, the let vCookie = TextBetween('$(vCookieRaw)','Secure,','Path=/',2);  is coming through as blank.  Are you able to advise please on what my issues may be?  

Many thanks for your time

Frank_S
Support
Support

@Senor_Dai 
Please check the following article very carefully.

https://community.qlik.com/t5/Support-Knowledge-Base/NPrinting-API-Setup-Requirements/ta-p/1715507

If you have check the above link thoroughly, please start a new community discussion outlining your issues and explain:

  • Steps to configure the solution
  • Steps to reproduce the issue
  • Expected results
  • Actual results
  • Version of Qlik Sense
  • Version of NPrinting

Thank you!

We are just 'like' you and like to be liked when providing a helpful answer. You may also press the 'Solution Accepted' button if an answer provided resolves your question or issue... Cheers!