17 Replies Latest reply: May 2, 2017 3:16 PM by Dicky Mohanty RSS

    Using a Session Cookie with Repository API

    Elva Lester

      I have a .NET MVC web application that requires SSL.  I am able to successfully access the Proxy Service to obtain a session ID and store it in my forms authentication cookie to allow for single sign-on.  I am able to display a specific app or sheet within an iframe by simply specifying the URL.  Instead of hard-coding the GUIDs for the apps and sheets, I would like to use the Repository Service to get a list of available apps and sheets.  Whenever I call qrs/virtualproxy/app/hublist, I get the html for the login screen returned.  I have tried adding various headers, but can't seem to find the right combination.  Here's my code:

       

      public string GetAppList(string method, string server, string virtualProxy, string user, string userdirectory, HttpCookie session)
      {
      string url = server + "/qrs/" + virtualProxy + "/app/hublist";

       

       

      //Create the HTTP Request and add required headers and content in Xrfkey
      string Xrfkey = "0123456789abcdef";
      HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url + "?Xrfkey=" + Xrfkey);
      request.Method = method;
      request.Accept = "application/json";
      request.ContentType = "application/json";
      request.Headers.Add("X-Qlik-Xrfkey", Xrfkey);
      request.Headers.Add("X-Qlik-User", "UserDirectory=" + userdirectory + ";UserId=" + user);
      request.Headers.Add("X-Qlik-Virtual-Proxy-Prefix", virtualProxy);

       

       

       

       

      // make the web request and return the content
      HttpWebResponse response = (HttpWebResponse)request.GetResponse();
      Stream stream = response.GetResponseStream();
      return stream != null ? new StreamReader(stream).ReadToEnd() : string.Empty;
      }

       

      Basically, I want the call to work like the .NET SDK command location.AsExistingSessionViaProxy(sessionCookie.Value, sessionCookie.Name).  Is this possible?

       

      Thanks.