Friday, November 13, 2015

Posting JSON data to WebAPI Always Null

I was playing with the JQuery and WebAPI and posting some data in JSON format to the Action.
In the Post Action of WebApi Controller [FormBody] Attributes catches the data, and we cast it in our respective type. I felt that send data in  JSON / JSON.stringify() so i must be cast in String type. but i get my data always null?

After several tries i changed the string type to dynamic and it solved my problem! :) 

public void Post([FromBody]dynamic value)
{
}


No comments:

Post a Comment