Base solution for your next web application
BLACK FRIDAY
From Nov 21
To Dec 1
XXDAYS : XXHRS : XXMIN : XXSEC
SAVE UP TO$3K
Also valid for the
existing customers!
Open Closed

How to fix this dynamic web api error. #633


0
junelee created

this is my service:

public interface IRoleAppService : IApplicationService
    {
        List<TestDto> Test(TestInputDto name);
    }

public class RoleAppService : TravellerAppServiceBase, IRoleAppService
    {
        public List<TestDto> Test(TestInputDto input)
        {
            return new List<TestDto> {new TestDto {Id = 1, Name = input.Name}};
        }
    }

this is the dto

public class TestInputDto : EntityRequestInput
    {
        public string Name { get; set; }
    }
     public class TestDto:EntityDto
    {
        public string Name { get; set; }
    }

when i use this dynamic web api, an error occurred. { "success": false, "result": null, "error": { "code": 0, "message": "对不起,在处理您的请求期间,产生了一个服务器内部错误!(Sorry, during the processing of your request, a server internal error has occurred!)", "details": null, "validationErrors": null }, "unAuthorizedRequest": false }

Can you help me to fix it? thx


3 Answer(s)
  • 0
    junelee created

    this is the post info

    POST /api/services/app/Role/test HTTP/1.1 Host: localhost:61754 Cache-Control: no-cache

    ----WebKitFormBoundaryE19zNvXGzXaLvS5C Content-Disposition: form-data; name="Name"

    test ----WebKitFormBoundaryE19zNvXGzXaLvS5C

  • 0
    junelee created

    "HttpResponseException: Processing of the HTTP request resulted in an exception. Please see the HTTP response returned by the 'Response' property of this exception for details.\r\nSTACK TRACE: 在 System.Web.Http.ModelBinding.FormatterParameterBinding.ReadContentAsync(HttpRequestMessage request, Type type, IEnumerable1 formatters, IFormatterLogger formatterLogger, CancellationToken cancellationToken)\r\n 在 System.Web.Http.ModelBinding.FormatterParameterBinding.ReadContentAsync(HttpRequestMessage request, Type type, IEnumerable1 formatters, IFormatterLogger formatterLogger)\r\n 在 System.Web.Http.ModelBinding.FormatterParameterBinding.d__0.MoveNext()\r\n--- 引发异常的上一位置中堆栈跟踪的末尾 ---\r\n 在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n 在 System.Runtime.CompilerServices.TaskAwaiter.GetResult()\r\n 在 System.Web.Http.Controllers.HttpActionBinding.d__0.MoveNext()\r\n--- 引发异常的上一位置中堆栈跟踪的末尾 ---\r\n 在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n 在 System.Runtime.CompilerServices.TaskAwaiter.GetResult()\r\n 在 System.Web.Http.Controllers.ActionFilterResult.d__2.MoveNext()\r\n--- 引发异常的上一位置中堆栈跟踪的末尾 ---\r\n 在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n 在 System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n 在 System.Web.Http.Controllers.ExceptionFilterResult.d__0.MoveNext()\r\n

  • 0
    hikalkan created
    Support Team

    Hi,

    Your code is simple actually. TestInputDto inherits EntityRequestInput but you did not provide id from the client. Does it still throws exception if you remove input for the method? Also, you may try to make customErrors = "Off" in the web.config to see full error.