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

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
JustinDallas
Specialist III
Specialist III

QlikSense C# SDK: location.SessionCookie throws an NPE

Hello Folks,

 

I'm working with the C# QlikSense SDK along with a Nov2019 Patch 3 QlikSense system.  When I connect, and ask for the cookie, I get {"Object reference not set to an instance of an object."}.  Below is the code that throws the error:

 

 

ILocation location = Qlik.Engine.Location.FromUri(uri);
location.AsNtlmUserViaProxy(proxyUsesSsl:uri.Scheme.Equals(Uri.UriSchemeHttps, 
    loginCredentials: new NetworkCredential(username,passwordSecureString,domain),
    certificateValidation: false);

//Throws error below.     
var cookie = location.SessionCookie;

 

 

 

However, if I connect and then do somethings with my location, I can then request the cookie with no problems.

 

 

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

using (new DebugConsole())
{
   var appIdentitifers = location.GetAppIdentifiers();
   var tractorHours2 = appIdentitifers.First(...
   var app = location.App(...);
   ISheetList sheetList = app.GetSheetList();
   foreach(ISheetObjectViewListContainer item in sheetList.Items)
   {
      //Below works
      var cookie = location.SessionCookie;

 

 

Is there anything I should be doing or know about concerning about when my cookie becomes available?

 

Any help is greatly appreciated.

Labels (2)
1 Solution

Accepted Solutions
Øystein_Kolsrud
Employee
Employee

The cookie is provided as part of the response headers when the websocket connection is established. So it is expected that the cookie will only be set after you perform a connection.

That said, triggering a null pointer exception is probably not the most users friendly way to handle that situation though...

View solution in original post

1 Reply
Øystein_Kolsrud
Employee
Employee

The cookie is provided as part of the response headers when the websocket connection is established. So it is expected that the cookie will only be set after you perform a connection.

That said, triggering a null pointer exception is probably not the most users friendly way to handle that situation though...