title: HttpDelete and parameters
body: <p>Created an ASP.NET Core Web API. With the following code, I can execute a Delete just fine from Postman with the Id in body.</p>
  
  <pre><code>    [Authorize]
  [Produces("application/json")]
  [Route("api/Gigs")]
  public class GigsController : Controller
  {
      private readonly ApplicationDbContext _context;
      private readonly UserManager&lt;ApplicationUser&gt; _userManager;
      private SignInManager&lt;ApplicationUser&gt; _signInManager;
  
      public GigsController(ApplicationDbContext context, UserManager&lt;ApplicationUser&gt; userManager, SignInManager&lt;ApplicationUser&gt; signInManager)
      {
          _context = context;
          _userManager = userManager;
          _signInManager = signInManager;
      }
  
  
      //[HttpDelete("{gigId}"]
      [HttpDelete]
      public IActionResult Cancel([FromBody] int gigId)
      {
          var userId = _userManager.GetUserId(User);
  
          var gig = _context.Gigs.Single(g =&gt; g.Id == gigId &amp;&amp; g.ArtistId == userId);
          gig.IsCancelled = true;
  
          _context.SaveChanges();
  
          return Ok();
  
      }
  
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/wNzav.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wNzav.png" alt="enter image description here"></a></p>
  
  <p>However, when I execute it via my webpage using the following JS code, I get a 500 Error. What is the correct way to pass the body text? I have also tried sending it as parameter without the [FromBody] and/or with [HttpDelete ("{gigId}")]</p>
  
  <pre><code>    &lt;script&gt;
      $(document).ready(function() {
          $(".js-cancel-gig").click(function(e) {
              var link = $(e.target);
              if (confirm("Are you sure you want to delete this gig?")) {
                  $.ajax({
                      url: "/api/gigs/",
                      method: "DELETE",
                      contentType: "application/json",
                      data: JSON.stringify({ "gigId": link.attr("data-gig-id") }),
                      success: function() {
                          link.parents("li").fadeOut(function() {
                              $(this).remove();
                          });
                      },
                      error: function() {
                          alert("something failed");
                      }
                  });
              }
          });
  
      });
  &lt;/script&gt;
  </code></pre>