How can I get the raw JSON dictionary from ASP.NET MVC Web API post?
asp.net-mvc, asp.net-mvc-4, asp.net-web-api, json, web-services
Solution
One option may be using one of the ReadAsAsync* methods in HttpContent instance off of the Request object
public void Post() {
var result = this.Request.Content.ReadAsAsync<string>().Result;
}
I don't know what format you're sending your data in, but you can retrieve it this way.
You could try this too for multiple objects...
public void Post(IEnumberable<Product> products) {
}
Problem
With a ApiController subclass, it has the ability in Post method to bind it to an existing model object such as ``` public class RegisterController : ApiController { public void Post(Product product) ``` but if the incoming JSON data contains data that I'll use to create multiple model objects, how can I get to the data directly? ``` public void Post(dynamic value) ``` returns value as null. Is there an easy shorthand way of getting to it like request.POST['name'] or something? Let's say the data looks like ``` { 'productID':1, 'productName':'hello', 'manufacturerID':1, 'manufacturerName':'world' } ```