ASP.NET Core 3.1 is taking POSTed JSON (for creating a user via SCIM v2 in my fledgling Web API) and model-binding it to my C# request-data class CreateUserRequest
like a champ. And it produces nice ProblemDetails-based errors if there is an error in the JSON.
E.g. if the user's last name (aka family name) is missing (which it shouldn't be because I [Require]
that property) then the response JSON is:-
{
"type": "https://www.rfc-editor.org/rfc/rfc7231#section-6.5.1",
"title": "One or more validation errors occurred.",
"status": 400,
"traceId": "|dbd3da85-4991c45298582047.",
"errors": {
"Name.LastName": [
"The LastName field is required.",
"The field LastName must be a string with a minimum length of 1 and a maximum length of 100."
]
}
}
This is the result of ValidationProblemDetails
and it's good for most purposes, but unfortunately it's not good for SCIM, which requires a different JSON format, described here.
E.g. SCIM errors look something like this:-
{
"schemas": ["urn:ietf:params:scim:api:messages:2.0:Error"],
"scimType":"mutability"
"detail":"Attribute 'id' is readOnly",
"status": "400"
}
How to replace ProblemDetails
and ValidationProblemDetails
with something else (in this case something SCIM-compatible) in ASP.NET Core 3.1 Web API?