Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

.net sdk to connect to a https qlik server

Hello,

I try to connect to a Qlik sense server and get an instance of an application to modify its content with the .Net SDK. I tried a lot of things, but I cannot achieve my work : the sdk documentation is very poor.

Please, could someone give me a piece of code which explains clearly how to connect to a qlik server and get an application, setting the credentials correctly ?

Knowing that :

- my server is in https mode

- I use to log using a login/password

- there is only the default proxy configured.

The documentation explains to do this :

Uri uri = new Uri(@"https://<server>");

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

but of course it does not works.

I can connect with the REST api without problem. But how to do it with .net code ? An how to get a full application instance ?

Thank you

Sebastien

8 Replies
Øystein_Kolsrud
Employee
Employee

Attaching to a Qlik Sense engine through the .Net SDK is a two step process where you first have to create a Location instance, and then configure the security settings of that location. The most common case for Qlik Sense server connections is to use NTLM, and such configurations are performed by running the Location member method AsNtlmUserViaProxy. If you for instance want to print the number of apps at a specific location, you could do like this:

var location = Location.FromUri(new Uri("<my server uri>"));

location.AsNtlmUserViaProxy();

Console.WriteLine("Number of apps: " + location.GetAppIdentifiers().Count());

I can recommend the following page if you want more details on how to connect to a Qlik Sense instance:

Connecting to Qlik Sense .Net SDK step-by-step

If you want more information concerning how to extract information from an app once you have connected, then I can recommend the "App traverser" example you can find in our examples section at the following location:

Download code samples

I hope this helps, and please let us know if there are any particular bottlenecks you encounter in getting started with the SDK.

Best regards,

Øystein Kolsrud

Not applicable
Author

Hello Øystein,


thank you for your answer.

Nevertheless, it appears to not working with my app. The version of the qlik engine is 2.1.1.0, as my server.

I exactly do this code :

Uri uri = new Uri("https://my-server-uri");

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

location.AsNtlmUserViaProxy();

Console.WriteLine(location.GetAppIdentifiers());

I even tried without proxy with port 4747, but whatever I do I get the following exception when calling GetAppIdentifiers (or any method):

Qlik.Engine.Communication.CommunicationErrorException

{"Connection failed after 4 attempts. Unable to keep connection open: Failed to ensure open connection: One or more errors occurred."}

There is no error log in server side.

My server seems to be correctly configured, as there is no strange option (everything is set by default).

I have no idea of what I could look at, there is no firewall on the server too.

Hope somebody could help...

Regards,

Sebastien

konrad_mattheis
Luminary Alumni
Luminary Alumni

Hi Sebastien,

>-I use to log using a login/password

can you login with the Internet Explorer Without putting your username & password?

If this is not working NTLM is not working.

Do you have to accept a not valid ssl certificate in IE?

I'm using the .NET SDK in the Sense Excel Plugin and a had now problems to connect

to server per https,...

bye

Konrad

Øystein_Kolsrud
Employee
Employee

Are you able to connect to the Qlik Sense server if you copy and paste the URL from your C# code to a browser? I just want to rule out the possibility of there being some error in the URL it self.

Also, are you using virtual proxies? You might have to configure the location object according to the section named "Qlik Sense Server with proxy" at the following page:

Step 2 - Accessing

Not applicable
Author

Well,

when I copy/paste the url in a browser, I can access my server but I need to enter my login/password by myself.

@Konrad, Using IE, I have to access a non valid certificate... I accepted it but it does not appears to change something. Should my errors come from this trouble ?

I tried to create a virtual proxy and call :

var location = Qlik.Engine.Location.FromUri(new Uri("https://<machine>"));
location.AsStaticHeaderUserViaProxy(userId, headerAuthenticationHeaderName, proxyUsesSsl:true);
location.VirtualProxyPath = "path/to/virtual/proxy";

where userId is my login,


or without proxy with :

var location = Qlik.Engine.Location.FromUri(new Uri("https://<machine>:4747"));
location.AsDirectConnection(userDirectory, userId, extendedSecurityEnvironment:false);


but whatever I get is the same error message as above...

Thank you.



Not applicable
Author

Hi,

In order to be able to connect to a Qlik Sense server you need to make sure your connection method corresponds to the Qlik Sense configuration.

If you have a Windows Active Directory you can use the following code to connect :

var location = Location.FromUri(new Uri("<my server uri>"));

location.AsNtlmUserViaProxy();

Make sure your Qlik Sense configuration has:

Virtual Proxy, Windows authentication pattern set to Windows

Websocket origin white list has your IP-adress or your domain (example microsoft.com)

Best regard

Lars-Göran Book

Øystein_Kolsrud
Employee
Employee

You should probably dig deeper into the security settings of your server like Lars-Göran suggests. Start by checking that your location is in the websocket white list by following these instructions:

  1. Go the the "Virtual proxies" section under "Configure System" in the QMC.
  2. Select the proxy you are trying to connect to and click "Edit".
  3. In the "Properties" list, make sure the section "Advanced" is checked.
  4. Your address should be listed in the "Websocket origin white list" section that appears.

You can read more about how to configure virtual proxies on the following site:

Editing virtual proxy

In particular you can learn more about the websocket white list under the "Advanced" section of the above page.

konrad_mattheis
Luminary Alumni
Luminary Alumni

Hi Sebastien,

>Using IE, I have to access a non valid certificate

I think this is not working with a non valid certificate. For testing change your server to http and test again.

If you have to put in your credentials I think your NTLM authentification is not working, so you can not authenticate over: location.AsNtlmUserViaProxy();

bye

Konrad