2017-11-27 12 views
2

jsonをAPIにポストすると、受信したボディは常にnullになります。私は、.NETコア2.0APIへのデータのポストはnullです

[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": "[email protected]", 
    "userName": "619795228409681", 
    "displayName": "Joe Samraj", 
    "firstName": "Joe Samraj", 
    "lastName": "Muthuraj", 
    "gender": "Male", 
    "yearOfBirth": "1989", 
    "attributes": [] 
} 

ヘッダーを掲示していますを使用しています。Content-Typeは:アプリケーション/ JSON

をここで間違っているでしょうか?

答えて

4

私は参考のために0〜255

間の値を受け入れますあなたはデータ型のビットとビットとyearofbirthフィールドを持っている...あなたのフィールドのデータ型に問題があると思います。このbyte datatype documentation

+0

感謝を参照してください@Saurabhソランキ:)。出来た。私は、この問題を引き起こした年齢から生年にそのフィールドを変更しました。 –

+0

歓迎Joe Samraj、もしこの答えがあなたのために働いたら、あなたは投票して答えを出すことができるので、あなたの質問を開いた他の人は、この回答が働いているかどうかを知ることができます。 –

+0

完了:)。再びありがとう:) –

関連する問題