Код: Выделить всё
[HttpPatch("update-name")]
public async Task UpdateName([FromBody] UpdateNameData data)
{
...
}
Код: Выделить всё
public class UpdateNameData
{
[Required(ErrorMessage = "Name is required")]
public string Name { get; set; } = string.Empty;
}
Код: Выделить всё
{
"type": "https://tools.ietf.org/html/rfc9110#section-15.5.1",
"title": "One or more validation errors occurred.",
"status": 400,
"errors": {
"data": [
"The data field is required."
],
"$.name": [
"The JSON value could not be converted to System.String. Path: $.name | LineNumber: 1 | BytePositionInLine: 10."
]
},
"traceId": "00-4cb41bb3f51e5253c5591ead5fccf96a-ea1c751ebed4be5b-00"
}
Подробнее здесь: https://stackoverflow.com/questions/783 ... e-is-wrong
Мобильная версия