I want to send an array in a JSON string to an API and then handle the data. Despite creating a class and trying to let it map it I get it as null
This is my AJAX call (part of):
var ids = {
rateplanIds: ['100', '200', '300']
};
$.ajax({
url: g_appVirtualPath + "ApiFile.mvc/CheckMBB/",
async: false,
global: false,
type: "POST",
data: {
ids: JSON.stringify(ids)
}
})
This is my API (part of):
public class RateplanIds
{
[DataMember]
public string[] rateplanIds { get; set; }
}
[AcceptVerbs(HttpVerbs.Post), Authorize]
public JsonResult CheckMBB(RateplanIds ids) //ids = null
{
}
contentType:"application/json"for your ajax requestdataType: "json"following the patern in other AJAX calls in the same project.datato what @Narendran has mentioned.dataidsis stillnullbut it is associated with the class. Previously it was justnullstring[]as a parameter in the controller