Reputation: 1835
I can't seem to be able to post data using a TableController via postman. I receive the following error:
{"message":"An error has occurred.","exceptionMessage":"Multiple actions were found that match the request: \r\nPostPerson on type CEVault.Backend.NetStandard.Controllers.Mobile.PersonController\r\nSetDomainManager on type CEVault.Backend.NetStandard.Controllers.Mobile.PersonController\r\nSetContext on type CEVault.Backend.NetStandard.Controllers.Mobile.PersonController\r\nSetContext on type CEVault.Backend.NetStandard.Controllers.Mobile.PersonController","exceptionType":"System.InvalidOperationException","stackTrace":" at System.Web.Http.Controllers.ApiControllerActionSelector.ActionSelectorCacheItem.SelectAction(HttpControllerContext controllerContext)\r\n at System.Web.Http.Controllers.ApiControllerActionSelector.SelectAction(HttpControllerContext controllerContext)\r\n at System.Web.Http.ApiController.ExecuteAsync(HttpControllerContext controllerContext, CancellationToken cancellationToken)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.d__1.MoveNext()"}
Looks like the server can't find the route. However all other actions/verbs work just fine (Patch, delete, get).
IN postman this is the code:
POST /tables/person HTTP/1.1
Host: localhost:43689 ZUMO-API-VERSION: 2.0.0 Content-Type: application/json Cache-Control: no-cache Postman-Token: 62bb9475-2b24-024a-b434-c9ddec0bcd9c
{ "deleted": false, "id": "81FEF95A-2B61-4CE6-B9F7-FEBD572DADD1", "avatar": "", "notes": null, "lastName": "Trumpet", "middleName": "Ignacio", "firstName": "Donald", "userId": "81FEF95A-2B61-4CE6-B9F7-FEBD572DA876" }
Any help is appreciated.
Upvotes: 2
Views: 195
Reputation: 18465
{"message":"An error has occurred.","exceptionMessage":"Multiple actions were found that match the request: \r\nPostPerson on type CEVault.Backend.NetStandard.Controllers.Mobile.PersonController\r\nSetDomainManager on type CEVault.Backend.NetStandard.Controllers.Mobile.PersonController\r\nSetContext on type CEVault.Backend.NetStandard.Controllers.Mobile.PersonController\r\nSetContext on type CEVault.Backend.NetStandard.Controllers.Mobile.PersonController","exceptionType":"System.InvalidOperationException",
According to your error message, I assumed that there are some actions (PostPerson
, SetDomainManager
,SetContext
) in your PersonController.cs which could both match your posted request.
Per my understanding, if you have some internal methods which are used to handle your business logic, you could mark them as protected or private instead of public. Or you could leverage RouteAttribute
(e.g. [Route("tables/TodoItem")]
) to mark your actions for attribute-based routing. When using RouteAttribute
, you need to enable it by adding the following code in the ConfigureMobileApp
method of your Startup.MobileApp.cs
:
config.MapHttpAttributeRoutes();
For more details, you could follow Adrian Hall's blog.
Upvotes: 4