Base solution for your next web application
Open Closed

Error about Dynamic WebApi #332


User avatar
0
lihuaming4000 created

I code my project IAppService and PersonAppService like the sample SimgpleTaskSystem .But the dynamic webapi has a error

{"message":"An error has occurred.","exceptionMessage":"There is an action GetTest defined for api controller huangbang/person but with a different HTTP Verb. Request verb is GET. It should be Post", ....

Please help me .I want to know it can change request verb ???


4 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    How did you called the web api? Can you share your calling code?

  • User Avatar
    0
    sergii created

    Same issue with api method

    http://localhost:6234/api/services/app/program/GetAllAssignments?id=1
    
    {"message":"An error has occurred.","exceptionMessage":"There is an action GetAllAssignments defined for api controller app/program but with a different HTTP Verb. Request verb is GET. It should be Post","exceptionType":"Abp.AbpException","stackTrace":"   at Abp.WebApi.Controllers.Dynamic.Selectors.AbpApiControllerActionSelector.GetActionDescriptorByActionName(HttpControllerContext controllerContext, DynamicApiControllerInfo controllerInfo, String actionName) in D:\\Halil\\GitHub\\aspnetboilerplate\\src\\Abp.Web.Api\\WebApi\\Controllers\\Dynamic\\Selectors\\AbpApiControllerActionSelector.cs:line 95\r\n   at Abp.WebApi.Controllers.Dynamic.Selectors.AbpApiControllerActionSelector.SelectAction(HttpControllerContext controllerContext) in D:\\Halil\\GitHub\\aspnetboilerplate\\src\\Abp.Web.Api\\WebApi\\Controllers\\Dynamic\\Selectors\\AbpApiControllerActionSelector.cs:line 48\r\n   at System.Web.Http.ApiController.ExecuteAsync(HttpControllerContext controllerContext, CancellationToken cancellationToken)\r\n   at Castle.Proxies.DynamicApiController`1Proxy_3.ExecuteAsync_callback(HttpControllerContext controllerContext, CancellationToken cancellationToken)\r\n   at Castle.Proxies.Invocations.ApiController_ExecuteAsync_3.InvokeMethodOnTarget()\r\n   at Castle.DynamicProxy.AbstractInvocation.Proceed()\r\n   at Abp.WebApi.Controllers.Dynamic.Interceptors.AbpDynamicApiControllerInterceptor`1.Intercept(IInvocation invocation) in D:\\Halil\\GitHub\\aspnetboilerplate\\src\\Abp.Web.Api\\WebApi\\Controllers\\Dynamic\\Interceptors\\AbpDynamicApiControllerInterceptor.cs:line 57\r\n   at Castle.DynamicProxy.AbstractInvocation.Proceed()\r\n   at Castle.Proxies.DynamicApiController`1Proxy_3.ExecuteAsync(HttpControllerContext controllerContext, CancellationToken cancellationToken)\r\n   at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"}
    
  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    It says the problem. You should make POST request, not GET. If you copy the URL to browser address bar, it will be GET request.

  • User Avatar
    0
    sergii created

    Correct, but I've fixed my issue by removing method overloads: Was

    IEnumerable<EntityDto> GetAllAssignments(int p1);
    IEnumerable<EntityDto> GetAllAssignments(int p1, int p2);
    

    Now

    IEnumerable<EntityDto> GetAllAssignments(int p1, int p2=0);