title: How do I fix a 400 Bad Request error in .Net Core POST operation?
body: <p>I have an .Net Core 2.1 API that posts data using EF core. When I make a POST request from Postman to http://localhost:3642/task/create I get a 400 Bad Request Error (The request cannot be fulfilled due to Bad Syntax).After digging around I got a suggestion to comment out the ValidateAntiForgery token from the controller. When I pass the request from postman with this change I get 200 Ok status message but no data is being committed to the table in Sql Server. Is there something that I should configure in my API, something else am I missing?</p>
  <p>My controller looks as follows:</p>
  <pre><code> [HttpPost]
   // [ValidateAntiForgeryToken]
   public async Task&lt;IActionResult&gt; 
  Create([Bind(&quot;Assignee,Summary,Description&quot;)] TaskViewModel taskViewModel)
      {
  if (ModelState.IsValid)
              {
                  _context.Add(taskViewModel);
   await _context.SaveChangesAsync();
                  return RedirectToAction(&quot;Index&quot;);
              }
              return View();
          }
  </code></pre>
  <p>In TaskViewModel.cs I have:</p>
  <pre><code> public class TaskViewModel 
  {
      [Required]
      public long Id { get; set; }
  
      [Required(ErrorMessage = &quot;Please provide Task Summary&quot;)]
      [Display(Name = &quot;Summary&quot;)]
      public string Summary { get; set; }
  
      [Required(ErrorMessage = &quot;Please enter task description&quot;)]
      [Display(Name = &quot;Description&quot;)]
      public string Description { get; set; }
  
      [Required(ErrorMessage = &quot;Please select Assignee&quot;)]
      [Display(Name = &quot;Assign To&quot;)]
      public string Assignee { get; set; }
  }
  </code></pre>
  <p>This is my payload in Postman:</p>
  <pre><code>{
      &quot;Assignee&quot;: &quot;Ed tshuma&quot;,
      &quot;Summary&quot;: &quot;Finish reconciliations&quot;,
      &quot;Description&quot;: &quot;collate all the pending data&quot;
  }
  </code></pre>