Acumatica - 创建SalesOrder时出错 - Variant / Subitem不能为空 - REST API
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Acumatica - 创建SalesOrder时出错 - Variant / Subitem不能为空 - REST API相关的知识,希望对你有一定的参考价值。
我目前正在使用Postman和Acumatica REST Api进行一些测试。我正在尝试使用PUT reqeust到Sales Order端点创建销售订单。我可以告诉我到达正确的端点并开始创建销售订单,但我不断收到Subitem不能为空的错误,即使我正在尝试将值传递给它。这是我的PUT请求的正文:
{
"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:UserscsilvaSourceReposSuperiorTextSuperiorTextSOOrderEntryExt.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)。到目前为止,我没有运气。
如何正确定位并为销售订单中的行项目分配子项目值?而且,这里有适当的文档吗?到目前为止我遇到的那些在这方面还不够全面。
得到它排序,希望这个信息将帮助其他发现自己处于类似情况的人。
正如@HB_ACUMATIA所指出的,Acumatica的默认6.00.001端点不包括允许由于某种原因分配Subitem字段的功能。因此,默认的扩展是使其工作的原因。这是一个图像,应该指出要做什么:
只需要转到Web服务端点页面(系统>集成> Web服务端点),选择默认值并扩展它。我将我的名字命名为CustomDefault。然后找到要修改的页面(在本例中为SalesOrder),然后是字段(Details)。在“字段”选项卡中,您可以添加一个新字段,将其命名为所需字段,并将其指向要提供的映射字段(在我的示例中,“Subitem”映射到Variant)。
然后修改HTTP请求以定位这个新端点(在我的情况下,我的公司名称和/ entity /之间的位从(W(blah)更改为)(W(8)),所以一定要留意为此:http://localhost/YourCompany/(W(8))/entity/CustomDefault/6.00.001/SalesOrder
起初,似乎这没有什么区别,但几分钟后地址或请求开始正确解决,我现在能够通过REST API提交销售订单。
作为最后一个例子,我的PUT请求的主体仍然如下所示:
{
"OrderType" : {"value": "SO"},
"CustomerID" : {"value": "300000014"},
"Details" :
[
{
"InventoryID" : {"value" : "EXAMPLEPRODUCT"},
"Subitem" : {"value" : "U"},
"Quantity": {"value" : 3}
}
]
}
编辑:
它似乎是6.00.001端点中的一个错误。
尝试使用此6.00.001 URL端点时,它会失败:http://localhost/xxxyyyzzz/entity/Default/6.00.001/SalesOrder/
随着17.200.001端点成功:http://localhost/xxxyyyzzz/entity/Default/17.200.001/SalesOrder/
最明显的解释是,因为项目'001'/'002'不存在子项'U',所以在执行验证时它将被设置为null。
您可以通过转到“销售订单”屏幕并按照以下步骤快速验证是否是这种情况:
- 在文档详细信息选项卡中插入一条新记录
- 选择“001”/“002”项目的库存ID
- 单击子项字段(仅在许可证中激活时可见)
- 按F3键
这将在选择器弹出窗口中显示有效子项值列表。确保项目'001'/'002'的子项'U'在那里:
我确实使用Postman成功复制了Web服务调用:
{
"OrderType" : { value: 'SO' },
"CustomerID" : { value: 'ABARTENDE'},
"Details" :
[
{
"InventoryID" : { value : 'AACOMPUT01'},
"Subitem" : { value : '0'},
"Quantity": { value : 1}
},
{
"InventoryID" : { value : 'ADMCHARGE'},
"Subitem" : { value : '0'},
"Quantity": { value : 2}
}
]
}
它创建了一个包含两个项目的新销售订单。我不认为你的JSON是坏的,试着用我的双重检查你的每一分钟语法细节相同。
例如,请注意您的示例中的值用引号括起来:
"Subitem" : {"value" : "U"},
虽然我的不是:
"Subitem" : {value : "U"},
以上是关于Acumatica - 创建SalesOrder时出错 - Variant / Subitem不能为空 - REST API的主要内容,如果未能解决你的问题,请参考以下文章
Acumatica 使用 PXLongOperation 恢复功能
Microsoft Dynamics NAV - 创建SalesOrder的新条目(Simple.OData.Client)