Passing through lists from jQuery to the service
        Posted  
        
            by 
                thedixon
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by thedixon
        
        
        
        Published on 2012-10-26T21:24:49Z
        Indexed on 
            2012/10/26
            23:00 UTC
        
        
        Read the original article
        Hit count: 242
        
I'm sure I've done this in another solution, but I can't seem to find any solution as to do it again and wondered if anyone can help me...
This is my WebAPI code:
public class WebController : ApiController
{
        public void Get(string telephone, string postcode, List<Client> clients)
        {
        }
}
And, calling this from jQuery:
    function Client(name, age) {
            this.Name = name;
            this.Age = age;
    }
    var Clients = [];
    Clients.push(new Client("Chris", 27));
    $.ajax({
        url: "/api/Web/",
        data: { telephone: "999", postcode: "xxx xxx", clients: Clients }
    });
But the "clients" object always comes back as null. I've also tried JSON.stringify(Clients), and this is the same result. Can anyone see anything obvious I'm missing here?
© Stack Overflow or respective owner