title: How to convert Curl command to HttpWebRequest in .net?
body: <p>Hello I am trying to consume a 3rd party Rest service using vs2010 .net and this is example of cURL command to get some data from this service:</p>
  
  <pre><code>curl -k --header "X-Authorization: authorizationString" -G -X GET -d 'message' https://WebsiteAddress.com/api/command/914
  </code></pre>
  
  <ol>
  <li>How to set parameters -G -X -GET? </li>
  <li>How to change -H header parameter to --header? Or do I have to do that?</li>
  </ol>
  
  <p>This is what I have so far:</p>
  
  <pre><code>string authorizationString = "bla bla";
  string message = "my Message";
  string url = "https://WebsiteAddress.com/api/command/914";
  var req = (HttpWebRequest)WebRequest.Create(url);
  req.ContentType = "application/json";
  req.Method = "Get";
  req.Headers.Add("X-Authorization", authorizationString);
  
  //bypassing untrusted certificate 
  //if DUBUG
  ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };
  //end DEBUG
  
  using (var PostData = new StreamWriter(req.GetRequestStream()))
  {
      PostData.Write(message);
      PostData.Flush();
  }
  
  var response = (HttpWebResponse)req.GetResponse();
  if (response.StatusCode == HttpStatusCode.OK)
  {
      //TO DO:
  }
  </code></pre>