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
using Microsoft.AspNetCore.Mvc;using Microsoft.AspNetCore.OData.Query;using Microsoft.AspNetCore.OData.Routing.Controllers;namespace ODataActionFailing.Controllers;[EnableQuery]publicclassWeatherForecastController(ILogger<WeatherForecastController> logger):ODataController{[HttpPost]public WeatherForecast Execute(intkey){
logger.LogInformation("We will only reach here with versions <= 8.1.2.\n"+"Any Version >= 8.2.0 will not reach here.");returnnew WeatherForecast(){Id=key};}}
Run the api. Make a POST request to the "Execute" endpoint.
Get an exception
Data Model
Please share your Data model, for example, your C# class.
Expected behavior
The POST request should reach to the controller and be handled there further.
Additional context
Exception Stack trace
System.ArgumentNullException: Value cannot be null. (Parameter 'type')
at Microsoft.OData.Edm.EdmUtil.CheckArgumentNull[T](T value, String parameterName)
at Microsoft.OData.Edm.EdmTypeSemantics.IsUntyped(IEdmType type)
at Microsoft.AspNetCore.OData.Query.EnableQueryAttribute.CreateQueryOptionsOnExecuting(ActionExecutingContext actionExecutingContext)
at Microsoft.AspNetCore.OData.Query.EnableQueryAttribute.OnActionExecuting(ActionExecutingContext actionExecutingContext)
at Microsoft.AspNetCore.Mvc.Filters.ActionFilterAttribute.OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
The text was updated successfully, but these errors were encountered:
From the stacktrace, it looks like it's something inside [EnableQuery] attribute that is breaking it. I take it if you remove the attribute, the problem goes away?
Not suggesting that as a solution, just to pin down where the issue could be.
From the stacktrace, it looks like it's something inside [EnableQuery] attribute that is breaking it. I take it if you remove the attribute, the problem goes away?
Not suggesting that as a solution, just to pin down where the issue could be.
Yes indeed. Removing [EnableQuery] "fixes" the issue.
But as you mentioned, that's of course not a suitable solution.
Assemblies affected
Not working -> Versions >= 8.2.0.
Working -> Versions between 8.0.2 and 8.1.2 (Tested)
Describe the bug
Sending a POST request to an endpoint which maps to an EdmModel.EntitySet.EntityType.Action fails.
Reproduce steps
<PackageReference Include="Microsoft.AspNetCore.OData" Version="8.2.4" />
to your projectpublic int Id { get; set; }
to WeatherForecast class to comply with OData keyData Model
Please share your Data model, for example, your C# class.
Request/Response
Request: POST https://localhost:7034/WeatherForecast(123)/Execute
Response: 500 - Value cannot be null. (Parameter 'type')
Expected behavior
The POST request should reach to the controller and be handled there further.
Additional context
Exception Stack trace
The text was updated successfully, but these errors were encountered: