title: Cisco Unified Call Manager (CUCM) AXL API throwing error when used in C#.net project
body: <p>I am trying to run a SQL query through AXL API in CUCM sandbox environment from my application and get back the SQL query result. Can anyone please let me know how we can do it through an example. I have attempted to do this, but getting an error "The underlying connection was closed: An unexpected error occurred on a receive" when  WebResponse resp = req.GetResponse(); is executed. Full code is shown below:</p>
  
  <pre><code>        HttpWebRequest req = (HttpWebRequest)WebRequest.Create(@"https://xx.xx.xx.xx/https/0/xx.xx.xx.x/axl/");
  
          //req.KeepAlive = false;
          req.ProtocolVersion = HttpVersion.Version10;
  
          req.Method = "POST";
          req.Host = "xx.xx.xx.x:8443";
          req.ProtocolVersion = System.Net.HttpVersion.Version10;
          req.ContentType = "text/xml";
          req.Accept = "text/xml";
          req.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes("username:password")));
  
          string strAXLRequest;
          strAXLRequest = "&lt;SOAP-ENV:Envelope xmlns:SOAP-ENV=";
          strAXLRequest += "\"http://schemas.xmlsoap.org/soap/envelope/\"";
          strAXLRequest += " xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\"";
          strAXLRequest += " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"";
          strAXLRequest += " xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"&gt; ";
          strAXLRequest += "&lt;SOAP-ENV:Body&gt; ";
          strAXLRequest += "&lt;m:executeSQLQuery xmlns:m=\"http://www.cisco.com/AXL/API/7.0\" sequence=\"1\"&gt; ";
          strAXLRequest += "&lt;m:sql&gt; ";
          strAXLRequest += "SELECT * FROM Device ";
          strAXLRequest += "&lt;/m:sql&gt; ";
          strAXLRequest += "&lt;/m:executeSQLQuery&gt; ";
          strAXLRequest += "&lt;/SOAP-ENV:Body&gt; ";
          strAXLRequest += "&lt;/SOAP-ENV:Envelope&gt;";
  
          System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };
  
  
          req.ContentLength = strAXLRequest.Length;
  
          Stream s = req.GetRequestStream();
          byte[] buffer = System.Text.Encoding.UTF8.GetBytes(strAXLRequest);
          s.Write(buffer, 0, strAXLRequest.Length);
          s.Close();
          try
          {
              WebResponse resp = req.GetResponse();
  
          s = resp.GetResponseStream();
          StreamReader sr = new StreamReader(s);
          string outputString = sr.ReadToEnd(); //Just output XML response
          sr.Close();
          s.Close();
          resp.Close();
          }
          catch (Exception ex)
          {
              string excep = ex.ToString();
          }
      }
  
  }
  </code></pre>
  
  <p>}</p>