Acumatica Rest API在代码中返回错误而不是Postman

时间:2017-11-07 23:57:52

标签: acumatica

这个问题让我疯了好几个小时,我无法弄清楚发生了什么。例如,我在Acumatica安装中的自定义页面上创建了一个测试操作。

此测试操作如下:

public PXAction<UsrPCMJob> testAction;
[PXUIField(DisplayName = "Test")]
[PXButton()]
public virtual void TestAction()
{
   throw new PXException("This is just a test action!");
}

我为此页面创建了一个休息端点并映射了测试操作。

如果我在Postman中创建帖子,它会按预期工作:

{"entity":{"Job":{"value":"0228467"}},"parameters":null}

我得到以下答案:

"exceptionMessage": "PX.Data.PXException: This is just a test action!

然而,在代码中(PHP,我的请求使用Guzzle),即使我的json主体是相同的:

{"entity":{"Job":{"value":"0228467"}},"parameters":null}

我收到此错误消息:

{"message":"An error has occurred.","exceptionMessage":"PX.Data.PXException: Error #251: Failed to commit the Job row.\r\n at PX.Api.SyImportProcessor.SyStep.a(Object A_0, PXFilterRow[] A_1, PXFilterRow[] A_2)\r\n at PX.Api.SyImportProcessor.ExportTableHelper.ExportTable()","exceptionType":"PX.Api.ContractBased.OutcomeEntityHasErrorsException","stackTrace":" at System.Monads.ArgumentCheck.CheckNull[TSource](TSource source, Func`1 exceptionSource)\r\n at PX.Api.ContractBased.EntityService.GetOperationResult(EntityImpl entity, EntityExportContextBuilder entityExportContextBuilder, PXSYTable exportedKeys, List`1 errors) in F:\\Bld2\\AC-FULL60U3-JOB1\\sources\\NetTools\\PX.Api.ContractBased\\EntityService.cs:line 457\r\n at PX.Api.ContractBased.EntityService.Invoke(ISystemContract systemContract, String version, String name, EntityImpl entity, ActionImpl action, CbOperationContext operationContext) in F:\\Bld2\\AC-FULL60U3-JOB1\\sources\\NetTools\\PX.Api.ContractBased\\EntityService.cs:line 720\r\n at PX.Api.ContractBased.Soap.EntityGateBase.InvokeImpl(EntityImpl entity, ActionImpl action) in F:\\Bld2\\AC-FULL60U3-JOB1\\sources\\NetTools\\PX.Api.ContractBased\\Soap\\EntityGateBase.cs:line 144\r\n at PX.Api.ContractBased.Soap.EntityGateV2.PX.Api.ContractBased.IRestGate.Invoke(EntityImpl entity, ActionImpl action) in F:\\Bld2\\AC-FULL60U3-JOB1\\sources\\NetTools\\PX.Api.ContractBased\\Soap\\EntityGateV2.cs:line 357\r\n at PX.Api.ContractBased.Soap.WebApiSoapController.RestInvoke(EntityEndpoint endpoint, String objectName, String actionName, ActionInvocation invocation) in F:\\Bld2\\AC-FULL60U3-JOB1\\sources\\NetTools\\PX.Api.ContractBased\\Soap\\WebApiSoapController.cs:line 414\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"}

我创建的php guzzle客户端在其他使用操作的请求上工作正常,但不适用于此测试操作或其他一些操作。

您可以提供任何帮助,我们将非常感激。谢谢!

0 个答案:

没有答案