Qlik Community

Qlik Sense Integration, Extensions, & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

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
Employee
Employee

Re: Connect to Qlik Sense via .NET SDK

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

6 Replies
Employee
Employee

Re: Connect to Qlik Sense via .NET SDK

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

Re: Connect to Qlik Sense via .NET SDK

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

Employee
Employee

Re: Connect to Qlik Sense via .NET SDK

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.

Employee
Employee

Re: Connect to Qlik Sense via .NET SDK

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

Re: Connect to Qlik Sense via .NET SDK

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

Re: Connect to Qlik Sense via .NET SDK

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

Community Browser