this is my client side ajax call:
var list = [\"a\", \"b\", \"c\", \"d\"];
var jsonText = { data: list };
$.ajax({
type: \
You can also do this with JSON.stringify
, which feels more semantically intuitive than putting things in an object with an empty string key. (I am using Web API 2, not sure if that matters.)
$.ajax({
type: 'POST', //also works for PUT or DELETE
url: '/api/UserRole',
contentType: "application/json",
data: JSON.stringify(["name1", "name2"])
})
[HttpPost]
[Route("api/UserRole")]
public IHttpActionResult AddUsers(string[] usernames)