I’m calling a WebMethod (ASP.NET) via AJAX (jQuery). If I create a version of the call with no params, it calls fine. When I pass my JSON into the real method, it doesn’t get called (breakpoint not getting hit). Here’s a sample of the JSON I’m passing in (array with 2 objects):
{
"bills":[
"{ 'Id': '1', 'Vote': 'true' },{ 'Id': '2', 'Vote': 'false' }"
]
}
Here’s the WebMethod signature:
[WebMethod]
public static void LinkBillsToCandidate(List<JsonBillForCandidate> bills)
Here’s the .NET object:
public class JsonBillForCandidate
{
public int Id { get; set; }
public bool? Vote { get; set; }
}
Is there a problem with my JSON format? That’s all I can think of that is preventing my call from going through.
The problem was as I had suspected. Some slight tweaking of the JSON did the trick. Here is the final JSON format that works:
This ASP.NET method handles the JSON just fine: