swagger .net core API ambiguous HTTP Action debugging

sammarcow picture sammarcow · Dec 14, 2017 · Viewed 29.1k times · Source

Implementing Swashbuckle/Swagger with .net Core 2 API I am now receiving the 500 error when accessing swagger.json:

NotSupportedException: Ambiguous HTTP method for action - EBisAPI.Controllers._class.HandleError (EBisAPI). Actions require an explicit HttpMethod binding for Swagger

I have gone through all the controllers and see explicit routing on all the public methods of each controller. Is there a way to determine which method is throwing the ambiguous routing error?

Answer

jps picture jps · Dec 15, 2017

This can occur when a method is declared public in a controller, but without REST attributes. Changing the method to protected may address the issue.

I have seen this error before and usually the errormessage points to the culprit: EBisAPI.Controllers._class.HandleError

I guess HandleError is a public method in your base class, right? Change it to protected and try again.