Acumatica - 创建销售订单时出错 - 变体/子项不能为空 - REST API [英] Acumatica - Error Creating SalesOrder - Variant/Subitem cannot be empty - REST API

查看:25
本文介绍了Acumatica - 创建销售订单时出错 - 变体/子项不能为空 - REST API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用带有 Acumatica REST Api 的 Postman 进行一些测试.我正在尝试使用对销售订单端点的 PUT 请求创建销售订单.我可以说我到达了正确的端点并开始创建销售订单,但我不断收到 Subitem 不能为空的错误,即使我正在尝试向它传递一个值.这是我的 PUT 请求的正文:

I am currently doing some testing using Postman with the Acumatica REST Api. I am trying to create a Sales Order using a PUT reqeust to the Sales Order endpoint. I can tell I'm reaching the right endpoint and am starting to create a sales order, but I keep getting an error that Subitem cannot be empty, even though I'm attempting to pass a value to it. Here is the body of my PUT request:

{
    "OrderType" : {value: "QT"},
    "CustomerID" : {value: 300000014},
    "Details" : 
    [
        {
            "InventoryID" : {"value" : "001"},
            "Subitem" : {"value" : "U"},
            "Quantity": {"value" : 1}
        },
        {
            "InventoryID" : {"value" : "002"},
            "Subitem" : {"value" : "U"},
            "Quantity": {"value" : 3}
        }
    ]
}

这是我收到的错误:

{
    "message": "An error has occurred.",
    "exceptionMessage": "PX.Data.PXException: Error: 'Subitem' cannot be empty.
 ---> PX.Data.PXOuterException: Error: Inserting  'Sales Order Line' record raised at least one error. Please review the errors.
   at PX.Data.PXUIFieldAttribute.CommandPreparing(PXCache sender, PXCommandPreparingEventArgs e)
   at PX.Data.PXCache.OnCommandPreparing(String name, Object row, Object value, PXDBOperation operation, Type table, FieldDescription& description)
   at PX.Data.PXCache`1.PersistInserted(Object row)
   at PX.Data.PXCache`1.Persist(PXDBOperation operation)
   at PX.Data.PXGraph.Persist(Type cacheType, PXDBOperation operation)
   at PX.Data.PXGraph.Persist()
   at PX.Objects.SO.SOOrderEntry.Persist()
   at SuperiorText.SOOrderEntryExt.Persist(PersistDelegate baseMethod) in C:\Users\csilva\Source\Repos\SuperiorText\SuperiorText\SOOrderEntryExt.cs:line 23
   at PX.Data.PXSave`1.<Handler>d__2.MoveNext()
   at PX.Data.PXAction`1.<Press>d__31.MoveNext()
   at PX.Data.PXAction`1.<Press>d__31.MoveNext()
   at PX.Api.SyImportProcessor.SyStep.a(Object A_0, PXFilterRow[] A_1, PXFilterRow[] A_2)
   at PX.Api.SyImportProcessor.ExportTableHelper.ExportTable()
   --- End of inner exception stack trace ---",
    "exceptionType": "PX.Api.ContractBased.OutcomeEntityHasErrorsException",
    "stackTrace": "   at PX.Api.ContractBased.EntityService.GetOperationResult(EntityImpl entity, EntityExportContextBuilder entityExportContextBuilder, PXSYTable exportedKeys, List`1 errors)
   at PX.Api.ContractBased.EntityService.Put(ISystemContract systemContract, String version, String name, EntityImpl entity, CbOperationContext operationContext)
   at PX.Api.ContractBased.Soap.EntityGateBase.PutImpl(EntityImpl entity)
   at lambda_method(Closure , Object , Object[] )
   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)
   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)
--- 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 System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.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 System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.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 System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.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 System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.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 System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__2.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 System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__0.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 System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"
}

我尝试了子项键的变体(例如Subitem"、SubItemID"和Variant")以及整数和字符串作为值(例如U"、0).到目前为止,我没有运气.

I have tried variations on both the sub item key (eg "Subitem", "SubItemID", and "Variant") as well as tried both integers and strings as the value (eg "U", 0). I have had no luck thus far.

如何为销售订单中的订单项正确定位和分配子项值?而且,在任何地方都有很好的文档吗?到目前为止我遇到的在这方面还不够全面.

How do I correctly target and assign the subitem value for a line item in a sales order? And also, is there good documentation for this anywhere? The ones that I've come across so far have not been comprehensive enough in this regard.

推荐答案

整理好了,希望这些信息能帮助其他遇到类似情况的人.

Got it sorted, hopefully this info will help anyone else that finds themselves in a similar situation.

正如@HB_ACUMATIA 指出的那样,Acumatica 的默认 6.00.001 端点由于某种原因不包括允许分配 Subitem 字段的功能.因此,默认值的扩展是使它起作用的原因.这是一张应该说明该怎么做的图像:

As @HB_ACUMATIA pointed out, Acumatica's Default 6.00.001 endpoint does not include functionality to allow the assigning of the Subitem field for some reason. So, an extension of the Default is what got this working. Here is an image that should get the point across on what to do:

只需要进入Web Service Endpoints页面(System>Integration>Web Service Endpoints),选择Default一个并扩展它.我将我的命名为 CustomDefault.然后找到要修改的页面(本例中为SalesOrder),然后是字段(Details).在字段"选项卡中,您可以添加一个新字段,将其命名为您想要的名称,并让它指向您要提供的映射字段(在我的例子中,子项"映射到 Variant).

Just need to go to the Web Service Endpoints page (System>Integration>Web Service Endpoints), select the Default one and extend it. I named mine CustomDefault. Then find the page to modify (SalesOrder in this case), and then the field (Details). In the Fields tab, you can add a new field, name it what you want, and have it point to the mapped field you want to supply ("Subitem" mapped to Variant in my case).

然后修改 HTTP 请求以针对这个新端点(在我的例子中,我的公司名称和/entity/之间的位从 (W(blah)) 更改为 (W(8)),因此请确保也保留睁大眼睛):http://localhost/YourCompany/(W(8))/entity/CustomDefault/6.00.001/SalesOrder

Then modify the HTTP request to target this new endpoint (in my case, the bit between my company name and /entity/ changed from (W(blah)) to (W(8)), so make sure to also keep an eye open for that) : http://localhost/YourCompany/(W(8))/entity/CustomDefault/6.00.001/SalesOrder

起初,这似乎没有什么区别,但几分钟后地址或请求开始正确解析,我现在可以通过 REST API 提交销售订单.

At first, it seemed like this didn't make a difference, but after a few minutes the address or request started to resolve correctly and I am now able to submit sales orders through the REST API.

作为最后一个示例,我的 PUT 请求的正文仍然如下所示:

Just as a final example, the body of my PUT request still looks like this:

{
    "OrderType" : {"value": "SO"},
    "CustomerID" : {"value": "300000014"},
    "Details" : 
    [
        {
            "InventoryID" : {"value" : "EXAMPLEPRODUCT"},
            "Subitem" : {"value" : "U"},
            "Quantity": {"value" : 3}
        }
    ]
}

这篇关于Acumatica - 创建销售订单时出错 - 变体/子项不能为空 - REST API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆