I am having a problem with silently failing deserialization in ASP.NET Web API (version 5.1.2). I would like the deserialization to raise an error instead but I am unable to find a configuration for it.
My specific (simplified) case is this. A client application (AngularJS) sends a HTTP POST request to the ASP.NET Web API backend. As a payload there are a bunch of strings:
["ABC100", "ABC200", "ABC300"]
However, the server is expecting a list of integers:
List<int> Ids { get; set; }
What ends up happening is that the deserialization fails, the Ids list will be empty and there are no errors.
Ids: []
Of course the mismatch needs to be fixed as well, but it seems obvious to me that the POST request should fail in this case. How can I make it the default?
array, it doesn't understandList<T>. List is aC#thing. And you are expectingint, whereas the values send by client are not.