Код: Выделить всё
{
"type": "https://tools.ietf.org/html/rfc9110#section-15.5.1",
"title": "One or more validation errors occurred.",
"status": 400,
"errors": {
"$.questions[0].answers": [
"The JSON value could not be converted to TestingService.Business.Features.V1.Test.Models.Answer[]. Path: $.questions[0].answers | LineNumber: 11 | BytePositionInLine: 20."
]
},
"traceId": "00-690e01e0fb451eed8afa4530616fa13f-0396f3a592bd1518-00"
}
Когда я использую промежуточное программное обеспечение, я тоже не могу перехватить это исключение.
Настройка моего контроллера:
Код: Выделить всё
services.AddControllers(options =>
options.Filters.Add(new ApiErrorFilter()))
.AddJsonOptions(options =>
{
options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
options.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
options.JsonSerializerOptions.Converters.Add(new Core.Infrastructure.DateTimeConverter());
});
Подробнее здесь: https://stackoverflow.com/questions/792 ... ue-to-a-js
Мобильная версия