I can\'t seem to get this to work... I have some jQuery like this on the client:
$.ajax({
type: \"POST\",
url: \"api/report/reportexists/\",
data
This worked for me, all other approaches didn't:
function addProduct() {
var product = { 'Id': 12, 'Name': 'Maya', 'Category': 'newcat', 'Price': 1234 };
$.ajax({
type: "POST",
url: "../api/products",
async: true,
cache: false,
type: 'POST',
data: product,
dataType: "json",
success: function (result) {
},
error: function (jqXHR, exception) {
alert(exception);
}
});
}
Serverside:
[HttpPost]
public Product[] AddNewProduct([FromBody]Product prod)
{
new List(products).Add(prod);
return products;
}