title: ASP Core 2 empty POST request
body: <p>I've got a simple HTTP POST request, which I send to an ASP Core 2 application running in localhost with Kestrel. The received data is always <code>null</code> unless I use <code>PostAsJsonAsync</code> from another C# app.</p>
  
  <p>The <code>json</code> I'm sending has this form:</p>
  
  <pre><code>{
    "_isValid": true,
    "_username": "test",
    "_guid": "f3f574eb-5710-43c5-a4ff-0b75866a72a7",
    "_dt": "2018-02-11T15:53:44.6161198Z",
    "_ms": "IsSelected"
    [...]
  }
  </code></pre>
  
  <p>The ASP controller has this form:</p>
  
  <pre><code>// POST: api/NativeClient
  [HttpPost]
  public async Task&lt;IActionResult&gt; Post([FromBody]string value)
  {
     [...]
  </code></pre>
  
  <p><strong>1. Case: sending with <code>PostAsJsonAsync</code> from another C# app</strong></p>
  
  <p>In one case I'm successfully sending the request via another separate C# application which uses <code>PostAsJsonAsync</code> like this:</p>
  
  <pre><code>HttpClient client = new HttpClient();
  client.BaseAddress = new System.Uri("http://localhost:51022/");
  client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
  
  var response = await client.PostAsJsonAsync("/api/NativeClient/", json);
  </code></pre>
  
  <p>The controller receives the call and populates <code>value</code> successfully.</p>
  
  <p><strong>2. Case: sending with an external REST client like Postman</strong></p>
  
  <p>In another case I try to send the request via another REST client, such as <a href="https://www.getpostman.com/" rel="nofollow noreferrer">Postman</a> or Visual Studio Code through <a href="https://marketplace.visualstudio.com/items?itemName=humao.rest-client" rel="nofollow noreferrer">REST client extension</a>:</p>
  
  <pre><code>POST http://localhost:51022/api/NativeClient/ HTTP/1.1
  content-type: application/json; charset=utf-8
  
  {
    "_isValid": true,
    "_username": "gnappo",
    "_guid": "f3f574eb-5710-43c5-a4ff-0b75866a72a7",
    "_dt": "2018-02-11T15:53:44.6161198Z",
    "_ms": "IsSelected"
    [...]
  }
  </code></pre>
  
  <p>Here the request is received by the controller, but the <code>string value</code> is always <code>null</code>.</p>
  
  <p>I've tried removing the <code>[FromBody]</code> tag, checking the request header, checking the json string in the body (which is exactly the same), and other things mentioned in the references below, but nothing works.</p>
  
  <p>What am I missing?</p>
  
  <hr>
  
  <p><strong>Other tests tried/references</strong></p>
  
  <p><a href="https://github.com/aspnet/Home/issues/2202" rel="nofollow noreferrer">Value are always null when doing HTTP Post requests</a></p>
  
  <p><a href="https://stackoverflow.com/questions/45862459/asp-net-core-2-api-post-objects-are-null">Asp.net Core 2 API POST Objects are NULL?</a></p>
  
  <p><a href="https://andrewlock.net/model-binding-json-posts-in-asp-net-core/" rel="nofollow noreferrer">Model binding JSON POSTs in ASP.NET Core</a></p>