string array values is not passing from JavaScript to controller method

I am trying to pass the values from JavaScript string array variable into controller method. The method is called but the value is not being passed. Here is my example

public IActionResult ReinstateEmployeeUpdate(List<string> employeeIds)
   return View( );
<script type="text/javascript">
function UpdateEmployee() {
        var employeeIds = [];         
        var employeeIds = ["346", "347"];
            type: "POST",
            contentType: "application/json",
            headers: { 'Content-Type': 'application/json' },
            url: "/Employee/ReinstateEmployeeUpdate",
            dataType: "json",
            data: JSON.stringify(employeeIds),
            success: function (response) {

            error: function (response) {

>Solution :

You could try as below:

    public IActionResult ReinstateEmployeeUpdate([FromBody]List<string> employeeIds)
       return View( );

Leave a Reply