向API发布数据为空

时间:2017-11-27 05:55:37

标签: asp.net-web-api asp.net-core

当我将一个json发布到API时,收到的正文总是为空。我正在使用.net core 2.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; }
}

Json我发帖

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

标题:内容类型:application / json

这里有什么问题?

0 个答案:

没有答案