<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic QlikSense C# SDK: location.SessionCookie throws an NPE in Integration, Extension &amp; APIs</title>
    <link>https://community.qlik.com/t5/Integration-Extension-APIs/QlikSense-C-SDK-location-SessionCookie-throws-an-NPE/m-p/1698509#M12720</link>
    <description>&lt;P&gt;Hello Folks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm working with the C# QlikSense SDK along with a Nov2019 Patch 3 QlikSense system.&amp;nbsp; When I connect, and ask for the cookie, I get&amp;nbsp;{"Object reference not set to an instance of an object."}.&amp;nbsp; Below is the code that throws the error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;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;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, if I connect and then do somethings with my location, I can then request the cookie with no problems.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;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;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there anything I should be doing or know about concerning about when my cookie becomes available?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is greatly appreciated.&lt;/P&gt;</description>
    <pubDate>Sat, 16 Nov 2024 02:32:02 GMT</pubDate>
    <dc:creator>JustinDallas</dc:creator>
    <dc:date>2024-11-16T02:32:02Z</dc:date>
    <item>
      <title>QlikSense C# SDK: location.SessionCookie throws an NPE</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/QlikSense-C-SDK-location-SessionCookie-throws-an-NPE/m-p/1698509#M12720</link>
      <description>&lt;P&gt;Hello Folks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm working with the C# QlikSense SDK along with a Nov2019 Patch 3 QlikSense system.&amp;nbsp; When I connect, and ask for the cookie, I get&amp;nbsp;{"Object reference not set to an instance of an object."}.&amp;nbsp; Below is the code that throws the error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;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;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, if I connect and then do somethings with my location, I can then request the cookie with no problems.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;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;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there anything I should be doing or know about concerning about when my cookie becomes available?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 02:32:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/QlikSense-C-SDK-location-SessionCookie-throws-an-NPE/m-p/1698509#M12720</guid>
      <dc:creator>JustinDallas</dc:creator>
      <dc:date>2024-11-16T02:32:02Z</dc:date>
    </item>
    <item>
      <title>Re: QlikSense C# SDK: location.SessionCookie throws an NPE</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/QlikSense-C-SDK-location-SessionCookie-throws-an-NPE/m-p/1698672#M12723</link>
      <description>&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;That said, triggering a null pointer exception is probably not the most users friendly way to handle that situation though...&lt;/P&gt;</description>
      <pubDate>Mon, 04 May 2020 07:12:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/QlikSense-C-SDK-location-SessionCookie-throws-an-NPE/m-p/1698672#M12723</guid>
      <dc:creator>Øystein_Kolsrud</dc:creator>
      <dc:date>2020-05-04T07:12:00Z</dc:date>
    </item>
  </channel>
</rss>

