我目前正在使用Postman和Acumatica REST Api进行一些测试。我正在尝试使用对销售订单端点的PUT需求创建销售订单。我可以说我到达了正确的端点并开始创建销售订单,但是我不断收到错误消息,即使我试图向其传递值,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.\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)。到目前为止,我还没有运气。
如何正确定位和分配销售订单中订单项的子项目值?而且,在任何地方都有良好的文档吗?到目前为止,我在这方面还不够全面。
答案 0 :(得分:1)
对它进行了排序,希望该信息将对其他遇到类似情况的人有所帮助。
正如@HB_ACUMATIA指出的那样,由于某种原因,Acumatica的Default 6.00.001端点不包含允许分配Subitem字段的功能。因此,对Default的扩展是使它起作用的原因。这是一张应该说明要做什么的图像:
只需转到Web服务端点页面(系统>集成> Web服务端点),选择默认值并将其扩展即可。我将其命名为CustomDefault。然后找到要修改的页面(在这种情况下为SalesOrder),然后是字段(详细信息)。在“字段”标签中,您可以添加一个新字段,将其命名为所需名称,并使其指向要提供的映射字段(在我的情况下,“子项目”映射到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}
}
]
}
答案 1 :(得分:0)
编辑:
这似乎是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”的子项目“ 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不错,请尝试与我的JSON仔细检查,并确保每分钟的语法细节都相同。
例如,请注意,示例中的值用引号引起来:
"Subitem" : {"value" : "U"},
不是我的:
"Subitem" : {value : "U"},