使用RESTAPI更新客户会导致500个内部服务器错误
我正在使用使用RESTAPI更新客户会导致500个内部服务器错误,rest,api,acumatica,guzzle,Rest,Api,Acumatica,Guzzle,我正在使用PHP和Guzzle 6通过基于合同的REST API更新AR客户记录,并得到500内部服务器错误响应 响应中的错误消息为: { "message": "An error has occurred.", "exceptionMessage": "Unable to cast object of type 'PX.Api.ContractBased.Models.EntityValueField' to type 'PX.Api.ContractBased.Models.En
PHP
和Guzzle 6
通过基于合同的REST API更新AR客户记录,并得到500内部服务器错误
响应
响应中的错误消息为:
{
"message": "An error has occurred.",
"exceptionMessage": "Unable to cast object of type 'PX.Api.ContractBased.Models.EntityValueField' to type 'PX.Api.ContractBased.Models.EntitySearchField'.",
"exceptionType": "System.InvalidCastException",
"stackTrace": "... see below ..."
}
堆栈跟踪:
at PX.Api.ContractBased.OData.FilterVisitor.SetNullableCondition(BinaryOperatorNode nodeIn, String nullCondition, String regularCondition)
at PX.Api.ContractBased.OData.FilterVisitor.VisitRoot(SingleValueNode root)
at PX.Api.ContractBased.OData.Helpers.FillRestQueryOptions(IEdmModel edmModel, EntityImpl entity, String filter, String select, String expand, String custom)
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.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()
此请求返回200成功响应:
PUTentity/Default/18.200.001/Customer?$filter=CustomerID%20eq%20%27100000044%27&$select=CustomerID
{
"CustomerClass": {
"value": "CUSTOMER_CLASS"
},
"CustomerID": {
"value": "100000044"
},
"CustomerName": {
"value": "Christiaan Raubenheimer"
},
"MainContact": {
"Address": {
"AddressLine1": {
"value": "Street Line 1"
},
"AddressLine2": {
"value": "Stree Line 2"
},
"City": {
"value": "City"
},
"Country": {
"value": "ZA"
},
"PostalCode": {
"value": "0000"
},
"State": {
"value": "State"
}
},
"Attention": {
"value": "Christiaan Raubenheimer"
},
"DisplayName": {
"value": "Company Name"
},
"Email": {
"value": "...email address..."
},
"JobTitle": {
"value": "Company Name"
},
"Phone1": {
"value": "0000000000"
}
}
}
{
"CustomerClass": {
"value": "CUSTOMER_CLASS"
},
"CustomerName": {
"value": "Christiaan Raubenheimer"
},
"MainContact": {
"Address": {
"AddressLine1": {
"value": "Street Line 1"
},
"AddressLine2": {
"value": "Stree Line 2"
},
"City": {
"value": "City"
},
"Country": {
"value": "ZA"
},
"PostalCode": {
"value": "0000"
},
"State": {
"value": "State"
}
},
"Attention": {
"value": "Christiaan Raubenheimer"
},
"DisplayName": {
"value": "Company Name"
},
"Email": {
"value": "...email address..."
},
"JobTitle": {
"value": "Company Name"
},
"Phone1": {
"value": "0000000000"
}
}
}
总之,如上所示,似乎需要从请求正文中删除
CustomerID
,但可能是我遗漏了什么吗?错误可能是因为您混合了多种选择记录的方法来更新它
您正在使用以下两种方式:
- URL中的筛选器参数
- 记录主体中的键字段
仅考虑使用其中一种方法。
< P>错误可能是由于混合了选择记录的多种方式来更新它。 您正在使用以下两种方式:- URL中的筛选器参数
- 记录主体中的键字段
只考虑使用其中的一种方法。
是否尝试检索信息或更新记录?通常,PUT请求用于更新或创建新记录,而filter参数更用于选择列表或特定记录。您好@samol518我正在尝试更新记录。查看链接的用户文档,$filter
参数可用于:指定用于标识要更新的记录的过滤条件在尝试检索信息或更新记录时?通常,PUT请求用于更新或创建新记录,而filter参数更用于选择列表或特定记录。您好@samol518我正在尝试更新记录。查看链接的用户文档,$filter
参数可用于:指定识别要更新的记录的过滤条件hanks@samol518,这也是我的怀疑!谢谢@samol518,这也是我的怀疑!