According to Scott Hanselman, on his blog, I should be able to do dynamic model binding and return a dynamic.
I have a Web API controller that contains a single method:
public dynamic Post(dynamic data)
{
return data;
}
When I make the following call from Fiddler, I am getting a null
returned.
POST http://localhost:57856/api/values HTTP/1.1
User-Agent: Fiddler
Host: localhost:57856
Content-Type: "application/json"
Content-Length: 22
{"Name": "jlucpicard"}
What am I missing here? Shouldn't it return JSON
for data
? This is a simpler follow-up to my original question ASP.NET WEB API not binding to dynamic object on POST.
Your action is returning null because your "data" parameter is not being bound to the incoming json data.
Remove the quotes from "application/json" in your Content-Type header to bind to the data.
Content-Type: application/json
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With