I'm building my first WebAPI using ASP.NET MVC 4 WebAPI.
The requests must be sent using the application/json ContentType with utf-8 as the character set.
My POST method looks like this:
public HttpResponseMessage Post([FromBody]string value)
{
return new HttpResponseMessage(HttpStatusCode.OK);
}
Whenever I'm sending a POST request the parameter 'value' is null. The request body contains Json: { "name":"test" }
.
What I prefer is to have the parameter of the Post method to be either a string containing the Json or be of type JObject (from the JSON.NET library). How do I accomplish this? And is this even possible?