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

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

问题描述

我目前正在使用Postman和Acumatica REST Api进行一些测试.我正在尝试使用对销售订单端点的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.\r\n ---> PX.Data.PXOuterException: Error: Inserting  'Sales Order Line' record raised at least one error. Please review the errors.\r\n   at PX.Data.PXUIFieldAttribute.CommandPreparing(PXCache sender, PXCommandPreparingEventArgs e)\r\n   at PX.Data.PXCache.OnCommandPreparing(String name, Object row, Object value, PXDBOperation operation, Type table, FieldDescription& description)\r\n   at PX.Data.PXCache`1.PersistInserted(Object row)\r\n   at PX.Data.PXCache`1.Persist(PXDBOperation operation)\r\n   at PX.Data.PXGraph.Persist(Type cacheType, PXDBOperation operation)\r\n   at PX.Data.PXGraph.Persist()\r\n   at PX.Objects.SO.SOOrderEntry.Persist()\r\n   at SuperiorText.SOOrderEntryExt.Persist(PersistDelegate baseMethod) in C:\\Users\\csilva\\Source\\Repos\\SuperiorText\\SuperiorText\\SOOrderEntryExt.cs:line 23\r\n   at PX.Data.PXSave`1.<Handler>d__2.MoveNext()\r\n   at PX.Data.PXAction`1.<Press>d__31.MoveNext()\r\n   at PX.Data.PXAction`1.<Press>d__31.MoveNext()\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()\r\n   --- 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)\r\n   at PX.Api.ContractBased.EntityService.Put(ISystemContract systemContract, String version, String name, EntityImpl entity, CbOperationContext operationContext)\r\n   at PX.Api.ContractBased.Soap.EntityGateBase.PutImpl(EntityImpl entity)\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()"
}

我已经尝试了子项键(例如"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的Default 6.00.001端点不包含允许分配Subitem字段的功能.因此,对Default的扩展是使此功能起作用的原因.这是一张应该说明如何做的图像:

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服务端点页面(系统>集成> Web服务端点),选择默认值并将其扩展即可.我将其命名为CustomDefault.然后找到要修改的页面(在这种情况下为SalesOrder),然后是字段(详细信息).在字段"标签中,您可以添加一个新字段,将其命名为您想要的名称,并使其指向您要提供的映射字段(在我的情况下,子项目"映射到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-创建SalesOrder时出错-变体/子项目不能为空-REST API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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