0
khai created
Hi, I always get the problem of validation in ASPNET Zero. Here are my things. To describe more the issue, I want to use ASPNETZero as the API Gateway. And with the same request data, I can POST successfully to the private API. Therefore, I don't know what is just happen with ASPNETZero Validation (the request just failed in the validation phase, and the program doesn't jump into the breakpoint inside LibraryAppService).
ILibraryAppService.cs
public interface ILibraryAppService : IApplicationService
{
Task ApiCategoryPostAsync(string tenantId, CategoryInput entityInput = null, CancellationToken cancellationToken = default(CancellationToken));
}
LibraryAppService.cs
public async Task ApiCategoryPostAsync(string tenantId, CategoryInput entityInput,
CancellationToken cancellationToken = default(CancellationToken))
{
_libraryClient = new LibraryHttpClient(_baseUrl, this.GetHttpClient());
await _libraryClient.ApiCategoryPostAsync(tenantId, entityInput, cancellationToken);
}
CategoryInput.cs
public class CategoryInput
{
[Required]
public TranslationInput CategoryName { get; set; }
public TranslationInput CategoryDescription { get; set; }
public string ParentId { get; set; }
[Required]
public ChosenBuildingInput[] BuildingStatusList { get; set; }
}
public class ChosenBuildingInput
{
public string BuildingId { get; set; }
public bool IsActive { get; set; }
}
TranslationInput.cs
public class TranslationInput
{
public string ENG { get; set; }
public string VIE { get; set; }
public string KHM { get; set; }
public string THA { get; set; }
public string LAO { get; set; }
public string CHI { get; set; }
public string KOR { get; set; }
public string JPN { get; set; }
}
Request Data (From Swagger)
curl -X POST --header 'Content-Type: application/json-patch+json' --header 'Accept: application/json' -d '{ \
"categoryName": { \
"eng": "Manga", \
"vie": "Manga Nhật Bản" \
}, \
"categoryDescription": { \
"eng": "Documents that is relevant to Manga", \
"vie": "Tài liệu liên quan đến truyện Manga" \
}, \
"buildingStatusList": [ \
{ \
"buildingId": "T1", \
"isActive": true \
}, \
{ \
"buildingId": "T2", \
"isActive": true \
} \
] \
}' 'http://localhost:5000/api/services/app/Library/ApiCategoryPostAsync?tenantId=3'
ResponseData:
{
"result": null,
"targetUrl": null,
"success": false,
"error": {
"code": 0,
"message": "Your request is not valid!",
"details": "The following errors were detected during validation.\r\n - \r\n",
"validationErrors": [
{
"message": "",
"members": [
""
]
}
]
},
"unAuthorizedRequest": false,
"__abp": true
}
Log File
WARN 2017-12-01 23:50:29,266 [9 ] Mvc.ExceptionHandling.AbpExceptionFilter - Method arguments are not valid! See ValidationErrors for details.
Abp.Runtime.Validation.AbpValidationException: Method arguments are not valid! See ValidationErrors for details.
at Abp.Runtime.Validation.Interception.MethodInvocationValidator.ThrowValidationError() in D:\Github\aspnetboilerplate\src\Abp\Runtime\Validation\Interception\MethodInvocationValidator.cs:line 128
at Abp.Runtime.Validation.Interception.MethodInvocationValidator.Validate() in D:\Github\aspnetboilerplate\src\Abp\Runtime\Validation\Interception\MethodInvocationValidator.cs:line 94
at Abp.AspNetCore.Mvc.Validation.AbpValidationActionFilter.<OnActionExecutionAsync>d__3.MoveNext() in D:\Github\aspnetboilerplate\src\Abp.AspNetCore\AspNetCore\Mvc\Validation\AbpValidationActionFilter.cs:line 35
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeNextActionFilterAsync>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeInnerFilterAsync>d__14.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeNextExceptionFilterAsync>d__23.MoveNext()
WARN 2017-12-01 23:50:29,275 [9 ] Mvc.ExceptionHandling.AbpExceptionFilter - There are 1 validation errors:
WARN 2017-12-01 23:50:29,275 [9 ] Mvc.ExceptionHandling.AbpExceptionFilter - ()
INFO 2017-12-01 23:50:30,821 [9 ] etCore.Mvc.Internal.ObjectResultExecutor - Executing ObjectResult, writing value Microsoft.AspNetCore.Mvc.ControllerContext.
INFO 2017-12-01 23:50:30,851 [9 ] ore.Mvc.Internal.ControllerActionInvoker - Executed action OnePlace.O1.OnePlace.Library.LibraryAppService.ApiCategoryPostAsync (OnePlace.O1.Application) in 5833.2027ms
INFO 2017-12-01 23:50:30,860 [9 ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 6335.7659ms 400 application/json; charset=utf-8