Why I got an 404 error when I try to post data to a WebAPI action?
C#:
public class ProductsController : ApiController
{
[HttpPost]
public List<Product> GetProductsByCategoryId(int categoryId, string title)
{
return new List<Product>
{
new Product { Id = 1 , Name = "Test" }
};
}
}
jQuery:
$.ajax({
url: '/api/products',
type: 'POST',
data: {
categoryId: 12,
title: 'ABC'
},
})