通过REST API添加新销售订单时出错-Acumatica

问题描述 投票:0回答:1

我正在尝试使用我在以下位置创建的自定义终结点向我的Acumatica系统添加包含明细行的新销售订单:

https://172.16.8.65/entity/ASG_INTEGRATION/6.00.001/SalesOrder

这是我在邮递员中发送的JSON正文:

{
    "OrderType": {  "value": "SO"     },
    "CustomerID": { "value": "6362212668"   },
    "Details": 
    [
        {
            "Account": {"value": "4040"            },
            "Branch": {"value": "00"                },
            "InventoryID": { "value": "33964"            },
            "OrderQty": { "value": 1.000000     }
        }
    ]
}

我必须创建自定义端点的原因是,我在详细销售订单项目必须中包含了“分支”字段,并且默认端点中没有填充“分支”字段领域。 (感谢此SO Question指出了解决该皱纹的方法!)

但是现在我收到以下错误(它不会告诉我在哪里寻找错误-至少可以看到...):

{
    "message": "An error has occurred.",
    "exceptionMessage": "PX.Data.PXException: Error: The system failed to commit the CurrentDocument row.\r\n   at PX.Api.SyImportProcessor.SyStep.a(Object A_0, PXFilterRow[] A_1, PXFilterRow[] A_2) in C:\\Bld2\\AC-FULL2019R113-JOB1\\Sources\\NetTools\\PX.Data\\Api\\Export\\SyImport\\ImportProcessor.cs:line 3638\r\n   at PX.Api.SyImportProcessor.ExportTableHelper.ExportTable() in C:\\Bld2\\AC-FULL2019R113-JOB1\\Sources\\NetTools\\PX.Data\\Api\\Export\\SyImport\\ImportProcessor.cs:line 1171",
    "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 C:\\Bld2\\AC-FULL2019R113-JOB1\\Sources\\NetTools\\PX.Api.ContractBased\\EntityService.cs:line 480\r\n   at PX.Api.ContractBased.EntityService.Put(ISystemContract systemContract, String version, String name, EntityImpl entity, CbOperationContext operationContext) in C:\\Bld2\\AC-FULL2019R113-JOB1\\Sources\\NetTools\\PX.Api.ContractBased\\EntityService.cs:line 474\r\n   at PX.Api.ContractBased.Soap.SoapFacadeBase.PutImpl(EntityImpl entity) in C:\\Bld2\\AC-FULL2019R113-JOB1\\Sources\\NetTools\\PX.Api.ContractBased\\Soap\\SoapFacadeBase.cs:line 117\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.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()"
}

您知道我的调试下一步要去哪里吗?

[[编辑:添加屏幕截图以解决费尔南多的问题]

有2个可能的分支,都具有相同的名称,并且您不能将它们都添加到实体中。Financial Settings Popup

这在文档详细信息中Document Settings

我应该使用哪个?我怎么知道???当我复制@Fernando显示的内容时(我假设使用文档详细信息“分支”),我收到“分支不能为空”错误:

Branch Cannot Be Empty

rest acumatica acumatica-kb
1个回答
0
投票

[好,我与费尔南多的对话很有帮助。这是我发现的,这是有效的:

在字段中选择“分支”的方式有两种不同的事实很重要。

一个出现在“文档详细信息”弹出窗口中Document Details Fields

[其中一个出现在财务设置->财务信息弹出窗口中:Financial Settings Field

事实证明两者都是必需的。 但是它们不能同时属于SalesOrder实体-不允许。

因此,我使用财务设置“分支”扩展了SalesOrder实体

Sales Order Entity Extension

而且,我用DocumentDetails“ Branch”扩展了SalesOrderDetail实体

enter image description here

然后我可以这样做,它被接受了:

{
        "CustomerID": { "value": "76758" },
        "OrderType": {  "value": "SO"      },
        "Branch": {  "value": "00"  },
        "Details": 
        [
            {
                "Account": {  "value": "4040"   },
                "Branch": {  "value": "00"  },
                "InventoryID": {  "value": "33964"},
                "OrderQty": {  "value": 1.000000  }
            }
        ]
    }

仅在那些位置之一设置分支机构不会创建可接受的销售订单记录。

© www.soinside.com 2019 - 2024. All rights reserved.