Код: Выделить всё
public class PostJobRequest
{
public int NumberOfThreads { get; set; }
public bool ReprocessSuccessful { get; set; } = true;
public bool ReprocessFailed { get; set; } = true;
public bool ProcessNew { get; set; } = true;
}
Код: Выделить всё
{
"NumberOfThreads": 4,
"ReprocessSuccessful": 1,
"ReprocessFailed": 1,
"ProcessNew": 1
}
Тогда платформа возвращает следующее сообщение об ошибке:
Код: Выделить всё
{
"type": "https://tools.ietf.org/html/rfc9110#section-15.5.1",
"title": "One or more validation errors occurred.",
"status": 400,
"errors": {
"request": [
"The request field is required."
],
"$.ReprocessSuccessful": [
"The JSON value could not be converted to System.Boolean. Path: $.ReprocessSuccessful | LineNumber: 2 | BytePositionInLine: 28."
]
},
"traceId": "00-00000000000000000000000000000000-0000000000000000-00"
}
Код: Выделить всё
{
"type": "https://tools.ietf.org/html/rfc9110#section-15.5.1",
"title": "One or more validation errors occurred.",
"status": 400,
"errors": {
"request": [
"The request field is required."
],
"$.ReprocessSuccessful": [
"The JSON value could not be converted to System.Boolean. Path: $.ReprocessSuccessful | LineNumber: 2 | BytePositionInLine: 28."
],
"$.ReprocessFailed": [
"The JSON value could not be converted to System.Boolean. Path: $.ReprocessFailed | LineNumber: 3 | BytePositionInLine: 24."
],
"$.ProcessNew": [
"The JSON value could not be converted to System.Boolean. Path: $.ProcessNew | LineNumber: 4 | BytePositionInLine: 19."
]
},
"traceId": "00-00000000000000000000000000000000-0000000000000000-00"
}
Код: Выделить всё
"$.ReprocessSuccessful": [
"The JSON value could not be converted to System.Boolean. Path: $.ReprocessSuccessful | LineNumber: 2 | BytePositionInLine: 28."
],
"$.ReprocessFailed": [
"The JSON value could not be converted to System.Boolean. Path: $.ReprocessFailed | LineNumber: 3 | BytePositionInLine: 24."
],
"$.ProcessNew": [
"The JSON value could not be converted to System.Boolean. Path: $.ProcessNew | LineNumber: 4 | BytePositionInLine: 19."
]
Код: Выделить всё
public class CustomModelStateFilter : IActionFilter
{
public void OnActionExecuting(ActionExecutingContext context)
{
}
}
Подробнее здесь: https://stackoverflow.com/questions/792 ... of-filters
Мобильная версия