-
Notifications
You must be signed in to change notification settings - Fork 711
The model is null in POST method when api-version is not specified and AssumeDefaultVersionWhenUnspecified = true #745
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
Comments
This ultimately has to do with OData model binding. The type should never be Since you say everything works as expected when the API version is explicitly specified, it seems the default version is not being set or resolved early enough. This would affect the resolution of the corresponding EDM and could produce the result you are seeing. I'll have to investigate. To unblock yourself, there are a few options. This is almost certainly a result of enabling var options = context.RequestServices.GetRequires<IOptions<ApiVersioningOptions>>();
var feature = context.Features.Get<IApiVersioningFeature>();
feature.RequestedApiVersion ??= options.DefaultApiVersion; app.UseMyMiddleware();
app.UseEndpoints(endpoints => { }); |
Hello Chris, |
Glad you have a functioning workaround. I have confirmed that this behavior is, in fact, a bug. This issue only happens when There is a strong affinity between API version and EDM. The This is why the model was This behavior will be corrected in the next patch. Thanks for all the input. The workaround should suffice in the meantime. |
…specified API version. Fixes #745
…specified API version. Fixes #745
…specified API version. Fixes #745
…pecified API version. Fixes #745
…pecified API version. Fixes #745
Uh oh!
There was an error while loading. Please reload this page.
I have a small OData Api with one Controller:
Model:
and the setup:
If I do a post JSON without specifying the api-version:
the default version is taken correctly, BUT model is null:
If I change the type of parameter to object:
the input parameter is not null but of type "System.Text.Json.JsonElement".
Why the json cannot be deserialized without specifying explicitly the api version?
if I add ?api-version=X.X everything works as expected and the input is nicely deserialized to the Asset model
The text was updated successfully, but these errors were encountered: