I am trying to send two arrays of object as post request parameters.
POST request from front-end in .cshtml file
var PostFunctions = {
PostTest: function () {
const sampleIds = [1, 2, 3];
const sampleStrings = ["1", "2", "3"];
var data = {
'sampleIds': sampleIds,
'sampleStrings': sampleStrings
};
$.ajax({
type: "POST",
url: "/Home/GetSamplesNames",
data: JSON.stringify(data),
async: false,
contentType: "application/json; charset=utf-8",
success: function () {}
});
}
};
GetSamplesNames() code in controller
[HttpPost]
public JsonResult GetSamplesNames([FromBody] List<UInt32> sampleIds, [FromBody] List<String> sampleStrings)
{
return new JsonResult(new List<String>() { "test" });
}
But in debug both parameters are null
What is my mistake with parameters stringify?.
Thank you in advance.