Asp.net web api 将数据过帐到API为空
当我将json发布到API时,收到的主体总是空的。我正在使用.NETCore2.0Asp.net web api 将数据过帐到API为空,asp.net-web-api,asp.net-core,Asp.net Web Api,Asp.net Core,当我将json发布到API时,收到的主体总是空的。我正在使用.NETCore2.0 [HttpPost] public IActionResult UpdateProfile([FromBody] UserProfileView userProfile) { return Ok(); } public class UserProfileView { [JsonProperty("id")] public string Id { get; set; } [Js
[HttpPost]
public IActionResult UpdateProfile([FromBody] UserProfileView userProfile)
{
return Ok();
}
public class UserProfileView
{
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("email")]
public string Email { get; set; }
public string UserName { get; set; }
public string DisplayName { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Gender { get; set; }
public byte? YearOfBirth { get; set; }
public List<UserAttribute> Attributes { get; set; }
}
标题:内容类型:application/json
这里出了什么问题?我认为您字段的数据类型有问题。您有数据类型为bit的yearofbirth字段,bit将接受0到255之间的值,因此您可以将yearofbirth的类型更改为datetime
有关参考信息,请参见此谢谢@Saurabh Solanki:)。成功了。我将该字段从年龄改为引起该问题的出生年份。欢迎Joe Samraj,如果这个答案对你有效,那么你可以投票并给出答案,这样其他提出你问题的人就会知道这个答案是否有效。完成:)。再次感谢:)
{
"id": "3e9f50c8-358a-4509-bbe4-4f4c6cc00676",
"email": "joesamraj@outlook.com",
"userName": "619795228409681",
"displayName": "Joe Samraj",
"firstName": "Joe Samraj",
"lastName": "Muthuraj",
"gender": "Male",
"yearOfBirth": "1989",
"attributes": []
}