简体   繁体   English

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

[英]Error Adding New Sales Order via REST API - Acumatica

I am trying to add a new sales order, with detail rows, to my Acumatica system using the a custom endpoint I created at:我正在尝试使用我在以下位置创建的自定义端点将带有详细信息行的新销售订单添加到我的 Acumatica 系统:

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

This is the JSON body I am sending in Postman:这是我在 Postman 中发送的 JSON 正文:

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

The reason I had to create the custom End Point was because the "Branch" field that I have on my detail sales order item must be included, and the Default end point did not have the Branch field in its populated fields.我必须创建自定义端点的原因是我的详细销售订单项目上的“分支”字段必须包括在内,并且默认端点的填充字段中没有分支字段。 (Thanks to this SO Question for pointing the way to that wrinkle!) (感谢这个SO Question指出了那条皱纹!)

But now I get the following error (which does not tell me where to look for the error -- at least that I can see...):但是现在我收到以下错误(它没有告诉我在哪里查找错误——至少我可以看到......):

{
    "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()"
}

Any idea where to go next in my debugging?知道我的调试下一步要去哪里吗?

[Edit:Adding screenshots to address Fernando's question] [编辑:添加屏幕截图以解决费尔南多的问题]

There are 2 possible branches, both named the same, and you cannot add both of them to an entity.有 2 个可能的分支,它们的名称相同,并且您不能将它们都添加到实体中。 财务设置弹出窗口

And this is in Document Details这是在文档详细信息中文档设置

Which one should I use?我应该使用哪一种? How can I know???我怎么知道??? When I replicate what @Fernando shows (I assume using the Document Details "Branch"), I get a "Branch cannot be Empty" error:当我复制@Fernando 显示的内容(我假设使用文档详细信息“分支”)时,出现“分支不能为空”错误:

分支不能为空

OK, my conversation with Fernando was helpful.好吧,我和费尔南多的谈话很有帮助。 Here's what I discovered, and here's what worked:这是我发现的,这是有效的:

The fact that there are two different ways of selecting "Branch" in the Fields is significant.在字段中有两种不同的选择“分支”的方式这一事实很重要。

One shows up in the "Document Details" PopUp一个显示在“文档详细信息”弹出窗口中文档详细信息字段

And one shows up in the Financial Settings -> Financial Information PopUp:一个出现在财务设置 -> 财务信息弹出窗口中: 财务设置字段

As it turns out BOTH are needed.事实证明两者都需要。 But they can't both belong to the SalesOrder Entity -- that's not allowed.但它们不能同时属于 SalesOrder 实体——这是不允许的。

So, I extended the SalesOrder Entity with the Financial Settings "Branch"因此,我使用财务设置“Branch”扩展了 SalesOrder 实体

销售订单实体扩展

And, I extended the SalesOrderDetail Entity with the DocumentDetails "Branch"并且,我使用 DocumentDetails“Branch”扩展了 SalesOrderDetail 实体

在此处输入图片说明

And then I could do this and it was accepted:然后我可以做到这一点,它被接受了:

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

Setting the branch in only one of those places would not create an accepted Sales Order record.仅在其中一个位置设置分支不会创建已接受的销售订单记录。 So this worked and I have a new Sales Order, with a detail line in it.所以这行得通,我有一个新的销售订单,其中有一个详细信息行。

I cannot remember now, because I tried so many different things, but, I believe that in the 18.200.001 version of SalesOrder, the Branch field already exists in the SalesOrder Detail, but not in SalesOrder.我现在记不清了,因为我尝试了很多不同的东西,但是,我相信18.200.001版本的 SalesOrder 中,Branch 字段已经存在于 SalesOrder Detail 中,但不存在于 SalesOrder 中。 And in the 6.00.001 version it doesn't exist in either.而在6.00.001版本中它也不存在。 I'm not sure, but I think that is how it is.我不确定,但我认为事情就是这样。 In case anyone stumbles across this and is using a different version...万一有人偶然发现并使用了不同的版本......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM