Acumatica REST API在调用和操作时返回错误

时间:2018-04-06 16:43:07

标签: acumatica

我做了一个动作,它在Acaumatica页面上运行良好。该操作调用另一个API连接。当我尝试在API WebEndpoint上调用操作时,我收到错误。

这是行动:

rotected virtual void giftCardDoPayment()
    {
        GiftCardPayment currentGCP = GiftCardPaymentView.SelectSingle();
        var client = CreateClient();
        var request = new GiftCardTransCreate
        {
            ProgramId = 33,
            Code = currentGCP.GiftCardNumber,
            Type = OnLoyalty.GiftCardTransType.ToPurchase,
            Amount = currentGCP.Amount,
            RegisterId = "POSRegister",
            RefNo = currentGCP.RefNo,
        };
        var response = client.Post(request);
        var paymentResults = PXCache<GiftCardPayment>.CreateCopy(GiftCardPaymentView.Current);
        paymentResults.TransactionID = response.TransactionId;
        paymentResults.CustomerCardNumber = response.Result.CustomerCardNumber;
        paymentResults.CustomerFullName = response.Result.CustomerFullName;
        paymentResults.Type = response.Result.Type;
        paymentResults.Status = response.Result.Status;
        paymentResults.Balance = response.Result.Balance;
        paymentResults.PendingAmount = response.Result.PendingAmount;
        paymentResults.ExpiresOn = response.Result.ExpiresOn;
        GiftCardPaymentView.Update(paymentResults); }

这是我对邮差的呼吁:

{
"entity" : {  
    "Amount": { "value": -18.00 },
    "GiftCardNumber": { "value": "7AE9ABBE-E25E-40E3-8ED9-BDEE23AAEEED" },
    "ReferenceNumber": { "value": "1234" } 
}

}

我得到的回应:

{
"message": "An error has occurred.",
"exceptionMessage": "Value cannot be null.\r\nParameter name: source",
"exceptionType": "System.ArgumentNullException",
"stackTrace": "   at System.Linq.Enumerable.Select[TSource,TResult](IEnumerable`1 source, Func`2 selector)\r\n   at PX.Api.ContractBased.EntityExportContextBuilder.BuildSearchCommands(EntityDescriptor descriptor, Boolean primaryViewOnly) in F:\\Bld\\AC-FULL61U12-JOB1\\sources\\NetTools\\PX.Api.ContractBased\\EntityExportContextBuilder.cs:line 1678\r\n   at PX.Api.ContractBased.EntityExportContextBuilder.<BuildUpdatePositioningCommands>d__58.MoveNext() in F:\\Bld\\AC-FULL61U12-JOB1\\sources\\NetTools\\PX.Api.ContractBased\\EntityExportContextBuilder.cs:line 1398\r\n   at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)\r\n   at PX.Api.ContractBased.EntityExportContextBuilder.BuildContextForInvoke(EntityDescriptor entityDescriptor, ActionImpl action, Boolean newEntity) in F:\\Bld\\AC-FULL61U12-JOB1\\sources\\NetTools\\PX.Api.ContractBased\\EntityExportContextBuilder.cs:line 1823\r\n   at PX.Api.ContractBased.EntityService.Invoke(ISystemContract systemContract, String version, String name, EntityImpl entity, ActionImpl action, CbOperationContext operationContext) in F:\\Bld\\AC-FULL61U12-JOB1\\sources\\NetTools\\PX.Api.ContractBased\\EntityService.cs:line 746\r\n   at PX.Api.ContractBased.Soap.EntityGateBase.InvokeImpl(EntityImpl entity, ActionImpl action) in F:\\Bld\\AC-FULL61U12-JOB1\\sources\\NetTools\\PX.Api.ContractBased\\Soap\\EntityGateBase.cs:line 145\r\n   at PX.Api.ContractBased.Soap.EntityGateV2.PX.Api.ContractBased.IRestGate.Invoke(EntityImpl entity, ActionImpl action) in F:\\Bld\\AC-FULL61U12-JOB1\\sources\\NetTools\\PX.Api.ContractBased\\Soap\\EntityGateV2.cs:line 358\r\n   at PX.Api.ContractBased.WebApi.Controllers.RestSystemContract2Controller.InvokeAction(EntityEndpoint endpoint, String objectName, String actionName, ActionInvocation invocation) in F:\\Bld\\AC-FULL61U12-JOB1\\sources\\NetTools\\PX.Api.ContractBased\\WebApi\\Controllers\\RestSystemContract2Controller.cs:line 86\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.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.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.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.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.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>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.Controllers.ExceptionFilterResult.<ExecuteAsync>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.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>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.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"}

0 个答案:

没有答案