I am sending data to a c# web api controller by using the following call.
$.ajax({
type: "POST",
url: "menuApi/menu/Cost",
data: JSON.stringify(order),
contentType: "application/json",
success: function (data) { window.alert('done')},
dataType: 'json'
});
The c# controller on server side is like this:
public string Cost([FromBody] string order)
{
var sOrder = Newtonsoft.Json.JsonConvert.DeserializeObject<dynamic>(order);
return "";
}
The order object in Javascript is a complex object with nested arrays and properties. I am getting data as null. I am not sure how can I get the order sent through the ajax call.
Edit: This is my order object
var order = {
name:"",
id:"",
cost:"",
details: {
sItem:[{name:"",cost:""}],
dItem:[{name:"",cost:"", components:[{name:"",quantity:""}]}]
}
}
orderapplication/json; charset=utf-8