Error: Action has more than one parameter bound from request body
My controller has some refactored code whose methods are marked public. Looks like either moving them out of the controller or marking private corrects this problem. Or attributing the pesky methods with [NonAction]
might also be a choice as asked at asp.net Core mvc hide and exclude Web Api Controller Method
For me in the definition of the a new controller automatically add this prerequisite.
I removed it and it works
[Route("api/[controller]")]
[Apicontroller] //remove this line
The error is coming from model binding and is not related to Swagger (the presence of ApiExplorerSettings
attribute has no impact on error).
You have two complex parameters. i.e. of Complex types
BeverageCapacityCampaign
BeverageCapacity
The default for Model Binding is to bind complex parameters from the body of the request. However, only one parameter per action may be bound from body.
So you need to either
- Combine them into one class that just wraps / holds both parameters as properties - and have them bound from the body (as one object)
- Decide which to bind from the body, and which from the route or the query and add the attributes [FromRoute] or [FromQuery] to one, and [FromBody] to the other.
ApiExplorerSettings
from System.Web.Http.Description
will ignore the attributed action from a help page, or whatever else (maybe swagger)... but you will still get this exception - from problems at level of Model Binding