title: c# How to send HTTP command as this - http://192.168.10.1/api/control?alert=101002
body: <p>I have this <a href="http://www.patlite.com/product/detail0000000224.html" rel="nofollow noreferrer">hardware</a> from Patlite,
  This hardware has an HTTP command control function, for example, if I copy the url "<a href="http://192.168.10.1/api/control?alert=101002" rel="nofollow noreferrer">http://192.168.10.1/api/control?alert=101002</a>" to chrome in my computer, it will activate the hardware as needed.</p>
  
  <p><strong>I want to send the command from my code.</strong></p>
  
  <p>I tried this code with no luck:</p>
  
  <pre><code>System.Net.ServicePointManager.Expect100Continue = false;
          WebRequest request = WebRequest.Create("http://10.0.22.222/api/control");
          request.Method = "post";
          request.ContentType = "application/x-www-form-urlencoded";
          string postData = "alert=101002";
          byte[] byteArray = Encoding.UTF8.GetBytes(postData);
          request.ContentLength = byteArray.Length;
          // Get the request stream.
          Stream dataStream = request.GetRequestStream();
  
          // Write the data to the request stream.
          dataStream.Write(byteArray, 0, byteArray.Length);
  
          // Close the Stream object.
          dataStream.Close();
          WebResponse response = request.GetResponse();
  </code></pre>
  
  <p>There is a picture from the manual:<a href="https://i.stack.imgur.com/qXkQm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qXkQm.png" alt="enter image description here"></a></p>
  
  <p>Thanks</p>