【问题标题】:REST API: Operation is not valid due to the current state of the objectREST API:由于对象的当前状态,操作无效
【发布时间】:2018-09-01 08:49:21
【问题描述】:

我在访问具有任意数量自定义功能的 DAC 中的数据时遇到问题。我有一个带有一些更复杂修改的 DAC,所以我将从简单的开始。我修改了SO.SOOrderExternal Reference 字段。这是对 DAC 的唯一更改。

原始属性

[PXDBString(40, IsUnicode = true)]
[PXUIField(DisplayName = "External Reference")]

自定义属性(替换原始属性)

[PXDBString(40, IsUnicode = true)]
[PXUIField(DisplayName = "Some Text Here")]

现在,当我尝试通过 REST API 访问任何 SalesOrder 时:

GET https://site.acumatica.com/entity/Default/17.200.001/SalesOrder/SO000123

返回如下错误:

{
    "message": "An error has occurred.",
    "exceptionMessage": "Operation is not valid due to the current state of the object.",
    "exceptionType": "System.InvalidOperationException",
    "stackTrace": "   at PX.Api.ContractBased.EntityService.FillEntityImplWithKeys(String version, String name, EntityImpl entity, String[] keys)
   at PX.Api.ContractBased.SystemContracts.V2.SoapFacade.PX.Api.ContractBased.IRestGate.FillEntityImplWithKeys(EntityImpl entity, String[] keys)
   at PX.Api.ContractBased.SystemContracts.V2.RestController.CreateEntityFromKeys(String objectName, String idsString)
   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()"
}

现在,我不确定这是否是因为我的 DAC 修改而发生的,但我找不到将这个和我其他有问题的 DAC CustomerLocation 与同一错误消息相关联的任何其他内容。

我该从哪里去确定坏状态是什么?

【问题讨论】:

  • 您使用的是哪个 Acumatica 版本?我知道这是 2017 年以后的事情,它到底是什么版本?
  • 确切的版本是17.205.0015

标签: rest api acumatica dac


【解决方案1】:

由于此屏幕包含多个关键字段(订单类型和订单编号),您需要将它们全部放在 URL 中。

GET https://site.acumatica.com/entity/Default/17.200.001/SalesOrder/SO000123

如果这是类型 SO 销售订单,则更改为

GET https://site.acumatica.com/entity/Default/17.200.001/SalesOrder/SO/000123

SO 是订单类型,00123 是订单号

【讨论】:

【解决方案2】:

此异常消息也可能是由于请求 URL 末尾的键字段之后的斜线字符引起的

例外:

http://site.acuamtica.com/entity/Default/17.200.001/SalesOrder/SO/SO123456/

成功:

http://site.acuamtica.com/entity/Default/17.200.001/SalesOrder/SO/SO123456

【讨论】:

    猜你喜欢
    • 2010-10-18
    • 1970-01-01
    • 2020-04-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多