Howe to define a custom error message when a non existent version is attempted. #1142
Replies: 1 comment
-
|
Note that you are versioning by URL segment, which is not RESTful (it violates the Uniform Interface constraint). One of the many consequences of this approach is that it is not always possible to return an error response. This limitation is due to how the ASP.NET routing system works. Since the version value is part of the path itself, there isn't an easy way for the routing system to reason about whether that particular path doesn't exist or whether it's just the an unsupported version. At the point in routing where this happens, the routing system is trying to match a path to the incoming request. Since there isn't a matched path yet, it isn't easy to determine if the route could match. In earlier versions of the library ( This is the only method of versioning that has this problem and limitation. All other versioning approaches have a stable URL path across versions, which means it's easy to collate candidates and determine whether they match the incoming request. If any endpoints can match, then you'll get an appropriate error response; otherwise, it will simply be |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
If I submit a test POST to my service and specify a version like
v1.2when the service only supportsv1.0andv2.0then I see a 404 response and nothing else (this is from Insomnia):I'd like to have a meaningful message returned. When I searched about this I found many posts about this kind of approach:
However there is no property named
ErrorResponsesnor type namedApiVersioningErrorResponseProviderso I suspect this is old, so is there a way to do this? I'm using this package FYI:Beta Was this translation helpful? Give feedback.
All reactions