2 Replies Latest reply: May 9, 2014 11:50 AM by Omer Demir RSS

    GetTicket using C#

    Daniel Lipkie

      Does anyone have an example of using GetTicket.aspx from within C#?

        • Re: GetTicket using C#
          Daniel Lipkie

          Make sure that credentialName is a member of "QlikView Administrators" on host.         public string GetTicket_WebRequest(string host, string user, string credentialName, string credentialPswd)         {             //WebRequest request = WebRequest.Create("http://" + host + "/QvAjaxZfc/GetTicket.aspx?admin=");             WebRequest request = WebRequest.Create("http://" + host + "/QvAjaxZfc/GetTicket.aspx");             string str = "" + user + "";             request.ContentLength = str.Length;             request.Method = "POST";             request.Credentials = new NetworkCredential(credentialName, credentialPswd);             StreamWriter writer = new StreamWriter(request.GetRequestStream());             writer.Write(str);             writer.Flush();             try             {                 StreamReader reader = new StreamReader(request.GetResponse().GetResponseStream());                 XmlDocument document = new XmlDocument();                 document.LoadXml(reader.ReadToEnd());                 if (document.InnerText.Length <= 0)                 {                     throw new Exception("Check QVS Host name / availability");                 }                 return document.InnerText;             }             catch (Exception exception)             {                 return exception.Message.ToString();             }         }

            • Re: GetTicket using C#
              Omer Demir

              Hi,

               

              I have implemented this code on my Asp page and called from page_load method, but it returned the

              "The underlying connection was closed: An unexpected error occurred on a receive"

              error on the following line:

              StreamReader reader = new StreamReader(request.GetResponse().GetResponseStream());

               

              My Qlikview server and web application are located on the same machine. Also the credentialname is a member of Qlikview Administrators Group.

               

              What could be the reason for this ?