Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net web api 将数据过帐到API为空_Asp.net Web Api_Asp.net Core - Fatal编程技术网

Asp.net web api 将数据过帐到API为空

Asp.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

当我将json发布到API时,收到的主体总是空的。我正在使用.NETCore2.0

[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": []
}