Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

GetTicket using C#

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

1 Solution

Accepted Solutions
Not applicable
Author

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();             }         }

View solution in original post

2 Replies
Not applicable
Author

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();             }         }

omerfaruk
Creator
Creator

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 ?