title: C# HttpWebResponse sendin null JSON string
body: <p>This has me really stumped. I have a Web API handler for POST that looks like this:</p>
  
  <pre><code>    [HttpPost]
      public IActionResult Post([FromBody]string jsonString)
      {
          if (jsonString == null)
              return new ObjectResult("Bad JSON");
  </code></pre>
  
  <p>My caller looks like this (borrowed from <a href="https://stackoverflow.com/questions/9145667/how-to-post-json-to-the-server">How to post JSON to the server?</a>):</p>
  
  <pre><code>    public async void PostJson(string path, string payload)
      {
          string url = string.Format("{0}{1}", BaseAddress, path); // Not the issue, the URL is good...
          var httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
          httpWebRequest.ContentType = "application/json";
          httpWebRequest.Method = "POST";
  
          using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
          {
              streamWriter.Write(payload);
              streamWriter.Flush();
              streamWriter.Close();
          }
  
          var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
          using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
          {
              var result = streamReader.ReadToEnd();
              Console.WriteLine(string.Format("Response: {0}", result.ToString()));
              Console.WriteLine("Press any key...");
              Console.ReadKey();
          }
  </code></pre>
  
  <p>}
  Here's the problem. When I use POSTMAN to post the JSON string (as supplied in payload), my WebApi gets the correct JSON string. Yet, when I use the code listed above (and many other methods I've tried by researching this) I consistently get a NULL value for jsonString in my web api. </p>
  
  <p>Can anyone shed any light on this?</p>