© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
3 replies
Nickolaki

❔ Change default behaviour of .NET Web API Validation Errors

Hi does anyone know how I can override the default problem details/validation error response .net gives when things like Guid and DateTime's are in an incorrect format?

{
    "type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
    "title": "One or more validation errors occurred.",
    "status": 400,
    "traceId": "00-9f2acabaefdccec268c6f8bc2594d0ba-bdd955faf7e6202a-00",
    "errors": {
        "command": [
            "The command field is required."
        ],
        "$.boardId": [
            "The JSON value could not be converted to System.Guid. Path: $.boardId | LineNumber: 0 | BytePositionInLine: 30."
        ]
    }
}
{
    "type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
    "title": "One or more validation errors occurred.",
    "status": 400,
    "traceId": "00-9f2acabaefdccec268c6f8bc2594d0ba-bdd955faf7e6202a-00",
    "errors": {
        "command": [
            "The command field is required."
        ],
        "$.boardId": [
            "The JSON value could not be converted to System.Guid. Path: $.boardId | LineNumber: 0 | BytePositionInLine: 30."
        ]
    }
}


I have implemented my own validation error responses but can't seem to avoid these type of ones firing^

Mine look like this:

{
    "status": 422,
    "message": "Validation errors occurred",
    "errors": [
        {
            "property": "BoardId",
            "message": "Board Id is required."
        }
    ]
}
{
    "status": 422,
    "message": "Validation errors occurred",
    "errors": [
        {
            "property": "BoardId",
            "message": "Board Id is required."
        }
    ]
}


FYI: my validation logic is driven by FluentValidation, I'm not using attributes etc.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ ASP.Net Core Web API
C#CC# / help
6mo ago
✅ Vue js + .Net Web Api
C#CC# / help
16mo ago
.Net 8 Web Api Config
C#CC# / help
16mo ago
✅ asp.net web api connection refused
C#CC# / help
2y ago