You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
NullReferenceException: Object reference not set to an instance of an object.
Microsoft.AspNet.OData.Routing.UnversionedODataPathRouteConstraint.Match(HttpContext httpContext, IRouter route, string routeKey, RouteValueDictionary values, RouteDirection routeDirection) in UnversionedODataPathRouteConstraint.cs, line 54
I'm using
Microsoft.AspNetCore.OData 7.2.1
and
Microsoft.AspNetCore.OData.Versioning 3.2.0.
This is my api config:
services.AddApiVersioning(options =>{options.AssumeDefaultVersionWhenUnspecified=true;options.ApiVersionReader=ASOFTApiVersions.CombineApiVersion;setupAction?.Invoke(options);});services.AddMvcCore(options =>options.EnableEndpointRouting=false);// Add odata and enable Apiversion supportservices.AddOData().EnableApiVersioning();services.AddSingleton(sp =>newODataUriResolver{EnableNoDollarQueryOptions=true});
I thought I had patched this already, but I guess I forgot or otherwise missed it. This is the same issue as described in #515. This will definitely be fixed and go out in the patch within the next few days.
The fix will properly produce 400 instead of a 500 from a NullReferenceException. This issue ultimately happens because no API version was specified and you allowed implicit versioning. Based on what I can discern from you configuration, that means the selected API version will be options.DefaultApiVersion, which is will have a default value of 1.0. The route will only match a controller mapped to 1.0 or is API version-neutral. It appears that neither of these were the case, which led down the path to produce a 400. Obviously, things should not blow up, but I'm willing to bet that either your route configuration is still incorrect or the client is not requesting the correct URL. If everything lines up, you shouldn't see this error, which should unblock you while I work on getting the patch out.
I have this issue when request query below:
http://localhost:60365/odata/Orders(20F37D86-3427-4A9E-8D63-16AEDDDB28FC,'BE')
NullReferenceException: Object reference not set to an instance of an object.
Microsoft.AspNet.OData.Routing.UnversionedODataPathRouteConstraint.Match(HttpContext httpContext, IRouter route, string routeKey, RouteValueDictionary values, RouteDirection routeDirection) in UnversionedODataPathRouteConstraint.cs, line 54
I'm using
and
This is my api config:
My model configuration:
And my action in controller:
The text was updated successfully, but these errors were encountered: