web-api POST body object always null

 

If the any of values of the request's JSON object are not the same type as expected by the service then the [FromBody] argument will be null.

For example, if the age property in the json had a float value:

"age":18.0

but the API service expects it to be an int

"age":18

then student will be null. (No error messages will be sent in the response unless no null reference check).

posted @ 2019-11-07 21:44  随碟附送520  阅读(181)  评论(0编辑  收藏  举报