title: How to make a PATCH request to am API with ASP.NET Core 2.2?
body: <p>I have an application that is written using <code>C#</code> on the top of ASP.NET Core 2.2. I created a controller that responds to a <code>PATCH</code> request called <code>Update</code>. Here is my controller</p>
  
  <pre><code>[Route("api/[controller]"), ApiController, Produces("application/json")]
  public class CategoriesController : ControllerBase
  {
      [HttpPatch("{propertyId}/{listId}/{isOn}"), Authorize]
      public ActionResult&lt;bool&gt; Update(int propertyId, int listId, bool isOn)
      {
          // Do something
          return true;
      }
  }
  </code></pre>
  
  <p>also, to return a 401 error when the user isn't authorized instead of a redirect, I added the following code to my <code>Startup</code> class</p>
  
  <pre><code>services.ConfigureApplicationCookie(config =&gt;
  {
      config.Events = new CookieAuthenticationEvents
      {
          OnRedirectToLogin = ctx =&gt;
          {
              if (ctx.Request.Path.StartsWithSegments("/api", StringComparison.CurrentCultureIgnoreCase))
              {
                  ctx.Response.StatusCode = (int)HttpStatusCode.Unauthorized;
              }
              else
              {
                  ctx.Response.Redirect(ctx.RedirectUri);
              }
  
              return Task.FromResult(0);
          }
      };
  });
  </code></pre>
  
  <p>Now to call this API using <code>jQuery</code> I did the following</p>
  
  <pre><code>$('.update-property').click(function (e) {
      e.preventDefault();
      var obj = $(this);
      $.ajax({
          url: '/api/Categories/Update',
          type: 'PATCH',
          data: {
              'propertyId': obj.data('property-id'),
              'listId': obj.data('list-id'),
              'isOn': obj.data('is-on') === 'True' ? 'false' : 'true'
          },
  
          success: function (response) {
  
              console.log(response);
  
              // if response unauthorized, redirect to the login page with the ReturnUrl
              // else if response.data is true then change the icon
          }
      });
  });
  </code></pre>
  
  <p>But this request keeps returning a 404 http error code. I inspected this question in the developer tools and I see that the parameter are being set correctly and the URL is valid.</p>
  
  <p>How can I correctly handle this PATCH request?</p>