Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Connect to Qlik Sense via .NET SDK

Hi All,

I refer to the following pages to try to connect Qlik Sense: Sample code for how to connect to Qlik Sense ‒ Qlik Sense, but I got below error:

'The remote certificate is invalid according to the validation procedure.'


I found the solution in Troubleshooting connection ‒ Qlik Sense and have installed the certificate on my local machine, it still doesn't work. My code is like below:


using System;

using Qlik.Engine;

using Qlik.Engine.Communication;

using System.Net;

using System.Net.Security;

namespace ConnectServerNTLM

{

    class Program

    {

        static void Main(string[] args)

        {

            var uri = new Uri("https://w12qs");

            if (args.Length > 0)

            {

                uri = new Uri(args[0]);

            }

            ILocation location = SetupConnection(uri);

            PrintQlikSenseVersionNumber(location);

        }

        private static ILocation SetupConnection(Uri uri)

        {

            ILocation location = Qlik.Engine.Location.FromUri(uri);

            var domain = "myDomain";

            var user = "myUserID";

            var pwd = "myPassword";

            location.AsNtlmUserViaProxy(proxyUsesSsl: uri.Scheme.Equals(Uri.UriSchemeHttps), loginCredentials: new NetworkCredential(user, pwd, domain));

            return location;

        }

        private static void PrintQlikSenseVersionNumber(ILocation location)

        {

            try

            {

                using (IHub hub = location.Hub(noVersionCheck: true))

                {

                    Console.WriteLine(hub.ProductVersion());

                }

            }

            catch (CommunicationErrorException cex)

            {

                Console.WriteLine("Can not connect to Qlik Sense instance, check that Qlik Sense is running." + Environment.NewLine + cex.Message);

            }

            catch (Exception ex)

            {

                Console.WriteLine("General error." + Environment.NewLine + ex.Message);

            }

            Console.ReadLine();

        }

    }

}

Thanks & Regards,

Shyee


1 Solution

Accepted Solutions
Øystein_Kolsrud
Employee
Employee

Try setting the "certificateValidation" parameter to "false" in your call to "AsNtlmUserViaProxy". Like this:

location.AsNtlmUserViaProxy(

  proxyUsesSsl: uri.Scheme.Equals(Uri.UriSchemeHttps),

  loginCredentials: new NetworkCredential(user, pwd, domain),

  certificateValidation: false);

ILocation.AsNtlmUserViaProxyAsync Method

View solution in original post

8 Replies
Øystein_Kolsrud
Employee
Employee

Try setting the "certificateValidation" parameter to "false" in your call to "AsNtlmUserViaProxy". Like this:

location.AsNtlmUserViaProxy(

  proxyUsesSsl: uri.Scheme.Equals(Uri.UriSchemeHttps),

  loginCredentials: new NetworkCredential(user, pwd, domain),

  certificateValidation: false);

ILocation.AsNtlmUserViaProxyAsync Method

Not applicable
Author

Thanks Kolsrud! I tried the solution but got another error: Method "QTProduct" timed out.

Øystein_Kolsrud
Employee
Employee

Hmm...What Qlik Sense version are you connecting to? For older versions you had to add your domain to the host white list in the QMC. That setting is found among the "Advanced" entries in the Virtual Proxy configurations.

Øystein_Kolsrud
Employee
Employee

It could potentially be a firewall setting as well. You could try to temporarily disabling the firewall and see if that makes a difference.

Not applicable
Author

Thanks Kolsrud!!!! I made it!!! Today I restart my pc and the program, it works!!! But I really don't know how did it work... I didn't set anything. Thank you so much!!

Not applicable
Author

PS: My Qlik Sense version is 3.2.0 and the program result just like picture attached, thx.微信截图_20171017102318.png

igorgois_
Partner - Creator
Partner - Creator

hello,

i am facing the same problem

server 1: my qlik sense enterprise hosted in azure, it worked in the first try

server 2:

  • I use VPN to access it
  • I do not have access to server firewall rules. Im getting QTproduct method timeout
  • url https://xxx/yyy/ is in the virtual proxy whitelist and when I type it in browser it opens the qlik sense hub
  • what can I change/ask to change in the firewall rules?

Thanks in advance

 

private void Form1_Load(object sender, EventArgs e)
        {     
            Uri uri = new Uri("https://xxx/yyy/");

            ILocation location = Qlik.Engine.Location.FromUri(uri);

            var domain = "xxxx";
            var user = "xxxx";

            var pass = "xxxx";

            location.AsNtlmUserViaProxy(
                certificateValidation: false,
                proxyUsesSsl: uri.Scheme.Equals(Uri.UriSchemeHttps),
                loginCredentials: new NetworkCredential(user, pass, domain));

            using (IHub hub = location.Hub())
            {

                NxEngineVersion engine = new NxEngineVersion();
                engine = hub.EngineVersion();
                label1.Text = engine.ComponentVersion;

            }

        }

 

Qiyanlu66
Partner - Contributor III
Partner - Contributor III

Hello Igor,

Have you solved the problem?
I have the same code as you, but whenever I run it, it's just shows:
System.Exception: Connection lost.

Thank you