title: Posting complex type in ASP.NET Core
body: <p>I am experiencing an issue while developing a restful webapi with .Net Core, I can't consume a HTTP POST method that inserts a complex type object without specifying the parameter as "FromBody". Accordingly to the documentation from Microsoft...</p>
  
  <p><a href="https://docs.microsoft.com/en-us/aspnet/web-api/overview/formats-and-model-binding/parameter-binding-in-aspnet-web-api" rel="noreferrer">Parameter Binding in ASP.NET Web API</a></p>
  
  <p>When using complex types on a HTTP POST I don't have to specify a <code>[FromBody]</code> data annotation, it should just work, but when I try to consume the method from the webapi...</p>
  
  <pre><code>// POST api/checker/
  [HttpPost]
  public int Insert(Entity e)
  {
      Console.WriteLine($"Entity: {e.ID} - {e.Name}");
  }
  </code></pre>
  
  <p>where entity has an id and a name, with this client method ...</p>
  
  <pre><code>string json = JsonConvert.SerializeObject(entity);        
  HttpClient client = new HttpClient();            
  HttpResponseMessage message         = await client.PostAsync(
          "http://localhost:5000/api/checker", 
          new StringContent(json, Encoding.UTF8, "application/json"));
  </code></pre>
  
  <p>The object reaches the webapi with the values 0 <code>(ID)</code> and null <code>(name)</code>, unless when the webapi method signature uses the <code>[FromBody]</code> annotation. Am I missing something here? I've already done a research and couldn't figure this out.</p>
  
  <p><strong>Update:</strong></p>
  
  <p>This is my entity class:</p>
  
  <pre><code>public class Entity
  {
      public int ID { get; set; }
      public bool IsDeleted { get; set; }
      public string Name { get; set; }
  }
  </code></pre>
  
  <p>This is the serialized json using Newtonsoft's JSON.NET:</p>
  
  <pre><code>{"ID":99,"IsDeleted":false,"Name":"TestChecker"}
  </code></pre>
  
  <p>This is the output from the insert web api method:</p>
  
  <pre><code>Entity: 0
  </code></pre>