Post FromBody Always Null

后端 未结 6 1466
伪装坚强ぢ
伪装坚强ぢ 2020-12-29 03:01

I\'ve got a new API that I\'m building with ASP.NET Core, and I can\'t get any data POST\'ed to an endpoint.

Here\'s what the endpoint looks like:

         


        
6条回答
  •  灰色年华
    2020-12-29 03:25

    You get always null because you need to encapsulate all your post variables inside only one object. Like this:

    public class MyPostModel {
        public List userSocs {get; set;}
        public int collegeId {get; set;}
    }
    

    and then

    public async Task GetStudentResults([FromBody] MyPostModel postModel)
    

提交回复
热议问题