web-api POST body object always null

前端 未结 26 3049
余生分开走
余生分开走 2020-11-27 15:03

I\'m still learning web API, so pardon me if my question sounds stupid.

I have this in my StudentController:

public HttpResponseMessage          


        
26条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-27 15:21

    I had the same problem.

    In my case, the problem was in public int? CreditLimitBasedOn { get; set; } property I had.

    my JSON had the value "CreditLimitBasedOn":true when It should contain an integer. This property prevented the whole object being deserialized on my api method.

提交回复
热议问题