-
Notifications
You must be signed in to change notification settings - Fork 707
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[OData] /odata/v1/orders() gives 400 Bad Request "Unspecified API version" #911
Comments
Strange, I don't see why that would happen based on your configuration. Everything looks correct. Out of curiosity, what happens if you don't use |
That is why I report it 😄, I didn't expect it either and was doubting myself, but since it does work without versioning, it has to be something with the versioning magic (or some other weird magic of course 😄) As shown in the table (😉) |
It might be surprising, but as configured, this is the expected behavior. By default, the configuration allows for the API version to be defined via the query string and a URL segment (e.g. the un-RESTful way). Extracting the API version from the URL is tricky. Since there are no suitable templates with the route constraint that match, the routing system presumes that Now, if you change the configuration to: builder.Services
.AddApiVersioning(options => options.ApiVersionReader = new UrlSegmentApiVersionReader())
.AddOData(options => options.AddRouteComponents("/odata/v{version:apiVersion}")) the API version can only come from a URL segment. Unfortunately, I believe I have a fix that will result in the desired behavior when versioning is restricted to just the URL. Any other combination will likely be |
Is there an existing issue for this?
Describe the bug
When trying to request a specific item, for example a product in de ODataBasicExample, but not providing a key:
GET ~/api/v1/orders()
, the service returns the following:Expected Behavior
I would expect (and removing versioning from the example confirms this) a 404 Not Found.
Steps To Reproduce
As an extra test I made a simple example here: https://github.com/dnperfors/eLibrary
The following requests give the following responses:
Exceptions (if any)
No response
.NET Version
6.0.300
Anything else?
Asp.Versioning.OData.ApiExplorer Version: 6.2.1
The text was updated successfully, but these errors were encountered: