title: C# Console Application httpWebRequest
body: <p>Im trying to create a very simple c# console application to post some data to a web api. However whatever I do I get an error on the response like:</p>
  
  <blockquote>
    <p>responseText  "{\"info\":{\"status\":\"failed\",\"error\":{\"code\":1000,\"message\":\"Invalid     argument from request\"}}}"    string</p>
  </blockquote>
  
  <p>The api <a href="http://www.detrack.com/api-documentation/" rel="nofollow">http://www.detrack.com/api-documentation/</a> is looking for a post like</p>
  
  <p><a href="https://app.detrack.com/api/v1/deliveries/view/all.json?key=dab13cc0094620102d89f06c0e464b7de0782bb979258d3a&amp;json=" rel="nofollow">https://app.detrack.com/api/v1/deliveries/view/all.json?key=dab13cc0094620102d89f06c0e464b7de0782bb979258d3a&amp;json=</a>{"date":"2014-08-29"}</p>
  
  <p>I know using this in chrome advanced rest application extension returns a valid result. But When I try the same via this console code. I get an error!.</p>
  
  <p>Here is the code I have in my console application.</p>
  
  <pre><code>using System;
  using System.Net;
  using System.IO;
  
  namespace ConsoleApplication1
  {
  class Program
  {
      static void Main(string[] args)
      {
  
          var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://app.detrack.com/api/v1/deliveries/view/all.json?key=dab13cc0094620102d89f06c0e464b7de0782bb979258d3a&amp;");
          httpWebRequest.ContentType = "application/json";
          httpWebRequest.Method = "POST";
  
          using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
          {
              string json = "json={\"date\":\"2014-08-28\"}";
              Console.WriteLine(json);
              streamWriter.Write(json);
          }
  
          var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
          using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
          {
              var responseText = streamReader.ReadToEnd();
              Console.WriteLine(responseText);
              Console.ReadKey();
  
          }
  
  
      }
  }
  }
  </code></pre>
  
  <p>Any help/guidance would be really appreciated</p>
  
  <p>brendan</p>