-
Notifications
You must be signed in to change notification settings - Fork 709
WebApi with ApiVersioning on dotNet Core fails to get param from body #452
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
Gold star for you - you've found a bug! :) The type test here is backward. It currently results in This is a quick fix. I'll get something out as quickly as possible. Thanks. |
Version 3.1.2 of the package with the fix has been published. Give it a few minutes to appear on NuGet. Let me know if you encounter any other issues. Thanks. |
@commonsensesoftware - Any chance we can get this fix added in 3.0 as well? We are currently using ASP.NET Core 2.1, so have to use the 3.0 version. |
@TracyGH, I'll give this a look to see the feasibility. It's a been a few months so I don't remember exactly where this fix diverges at. As you can imagine, managing parallel branches (by myself no less) can be difficult. On occasion, I have backported. Normally, this is a no-brainer if I just need to forward the branch a few commits without the version. If I have to cherry pick, then things get a little dicier; especially if more changes are requested. Regardless, I'll review this and see what can be done. |
@commonsensesoftware - Thank-you for following up! I was struggling to upgrade our projects to ASP.NET Core 2.2, but finally got it worked out. So, no worries on the backport unless you have other users who need it as well. |
I have a dotNet Core server which is a middleware between mobile applications and a third party server. This server is used just to add an SSL certificate and make requests, rather installing certificates on every single device.
I've created some controllers and the endpoints have a signature similar to this:
public async Task VerifyOrder([FromBody] object request,....)
This worked perfectly fine until I decided to add API Versioning. In order to accomplish this, I've added in Startup.cs the following code block in the ConfigureServices method:
services.AddApiVersioning(o =>
{
o.AssumeDefaultVersionWhenUnspecified = true;
o.DefaultApiVersion = new ApiVersion(1, 0);
o.ApiVersionReader = new MediaTypeApiVersionReader();
o.ApiVersionSelector = new CurrentImplementationApiVersionSelector(o);
o.ReportApiVersions = true;
});
After this modification, when making requests instead of getting the body as an object, I'm getting the version which is set at the controller level.
As a workaround, I changed the type of request param to be JObject but, I think it should work with an object as well.
Thanks,
Andrei Robu
The text was updated successfully, but these errors were encountered: