Qlik Community

Qlik NPrinting Discussions

Discussion Board for collaboration on Qlik NPrinting.

Announcements
IMPORTANT: PLEASE READ - Labels will be required in the NPrinting forum starting on Friday September 26, 2019: Click here for details and instructions.
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 (5)
1 Solution

Accepted Solutions
Highlighted
Partner
Partner

Re: Connecting to the API using REST connector

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.

3 Replies
Support
Support

Re: Connecting to the API using REST connector

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 & like to be liked when we provide a helpful answer and or when you press the 'Solution Accepted' button if an answer provided resolves your question or issue... Cheers!
Partner
Partner

Re: Connecting to the API using REST connector

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.

 

Highlighted
Partner
Partner

Re: Connecting to the API using REST connector

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.