I seem to have run into an interesting problem with Web API - using this controller action, with a breakpoint on the opening brace to inspect thing:
[HttpPut]
public void Test([FromBody]object thing)
{
}
If I submit the following request (as CURL), I get the expected value which is a JObject containing the data from the body:
curl -X PUT -H "Content-Type: application/json" -d '{
"Name": "Joe",
"Key": { "Key": "Value" }
}' "http://localhost/api/TestController/Test"
That is, an anonymous object where Name is Joe and Key is another object containing Key = Value.
However, if I change this ever-so-slightly to instead submit an array of Keys, I get null. No error, just null.
curl -X PUT -H "Content-Type: application/json" -d '{
"Name": "Joe",
"Keys": [{ "Key": "Value" }]
}' "http://localhost/api/TestController/Test"
Why is this happening? The HTTP verb doesn't seem to matter (I've tried POST and PUT), and using dynamic instead of object is the same thing.



