Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
berndpodhradsky
Partner - Contributor III
Partner - Contributor III

.NET SDK with Qlik Sense Business

Hi everyone!

Currently the .NET SDK does not support to connect to a Qlik Sense Business instance. Are there any plans to include that functionality in the near future? Or what are alternative solutions?

Kind Regards,
Bernd

Labels (2)
16 Replies
Øystein_Kolsrud
Employee
Employee

That is certainly odd... But yes I can confirm that I can see the visualization with the correct selection state. I have connected to the same app in both Firefox and Chrome. Then in Chrome I'm using a plugin to modify headers, and there I've added a header named "X-Qlik-Session" with the value "MyToken". I can see that this makes the selection state independent between the two browser. So if I do a selection in Chrome, then that won't propagate to my session in Firefox. If I disable the custom header in Chrome, then the selection state is correctly synced between the two browsers.

Then what I have done is to make a selection in Chrome (with the header enabled), and then do a .NET SDK connection to the same app according the the description above where I explicitly set the "SessionToken" property to "MyToken". I can then see that the selection state of the session I get through the SDK is the same as the one I have in Chrome. I take it this is the behavior you are looking for?

berndpodhradsky
Partner - Contributor III
Partner - Contributor III
Author

That's strange. I think we're pretty close to the solution but there's something I must be missing. Would you mind sharing a small .NET solution with your working code where I can paste my API key, URL and AppID?

Bernd

Øystein_Kolsrud
Employee
Employee

This is it ("url", "token" and "appId" are all strings):

 

static void Main(string[] args)
{
    var location = Location.FromUri(url);
    location.AsJwtViaProxy(token);
    var appIdentifier = new AppIdentifier {AppId = appId};
    var session = Session.WithApp(appIdentifier);
    session.SessionToken = "MyToken";
    using (var app = location.App(appIdentifier, session))
    {
        Console.WriteLine(app.Evaluate("=Count(distinct Dim1)"));
    }
}

My guess is that the problem you are facing is related to that unexpected "X-Qlik-Session" value that you observed. Try to trace where that is coming from! The default session value will not be a GUID when you use "Session.WithApp", but a string of the form "/app/<appId>".

 

berndpodhradsky
Partner - Contributor III
Partner - Contributor III
Author

Hi!

The X-Qlik-Session I get is not a GUID but in the form you mentioned; so it seems to be the default token.

Unfortunately things still don't work on my end and I'll try out different things. However, to be honest it's quite frustrating that this is nowhere documented. Wouldn't it make much more sense for Qlik to provide an API that takes care of that stuff under the hood and gives developers a single, uniform experience?

Trying not to complain too much here and I hope you don't get it wrong :). But at the end of the day we're trying to devliver enterprise-ready solutions and it's a bit hard to do that if the feature we're implementing seems to be a bit shaky and undocumented (and could change with every update of QSB, because it's an unofficial way of doing it).

In addition to that the fact that Qlik might throttle API calls and simply reject their execution doesn't help either :).

Bernd

 

Øystein_Kolsrud
Employee
Employee

I feel your pain... The main source of information about QCS related APIs is this site:

https://qlik.dev/

It contains a lot of useful information, but a description of how that session identification works is missing today. You might want to write a note using the "leave feedback" functionality of that site. Such feedback is typically very much appreciated and quite useful for prioritization purposes.

But back to the thread... When you write "things still don't work on my end", do you mean that the code I sent doesn't work for you or that the code you wrote still isn't working?

berndpodhradsky
Partner - Contributor III
Partner - Contributor III
Author

Hi!

The code works, but that scenario has always worked for me. But if I filter a field using the .NET SDK and then open a visualization in a browser with the session header, it displays as if the filter wasn‘t there.

Bernd
Øystein_Kolsrud
Employee
Employee

FYI: The latest release of the SDK includes a new class designed for interacting with a QCS location:

https://help.qlik.com/en-US/sense-developer/November2020/Subsystems/NetSDKAPIref/Content/Qlik.Sense....

Using that class, you should be able to define your connection like this:

 

var location = QcsLocation.FromUri(uri);
location.AsApiKey(apiKey);
using (var app = location.App(appId, SessionToken.Custom("MyToken")))
{
    Console.WriteLine(app.GetAppProperties().Title);
}