Post FromBody Always Null

后端 未结 6 1460
伪装坚强ぢ
伪装坚强ぢ 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:23

    If you want to send two or more models, you should use this example:

    [HttpPost]
    public async Task addUsuario([FromBody] Newtonsoft.Json.Linq.JObject datos)
    {
        Usuarios user = datos["usuario"].ToObject();
        Empresas empresa = datos["empresa"].ToObject();
        return Json(await _srv.addUsuario(user, empresa));
    }
    

提交回复
热议问题