Acumatica采购收据更新错误:序列不包含匹配元素



(以下都是我直接通过Postman向Acumatica发送请求)

在附加文件到购买收据之前,我可以按照我的意愿更新任何购买收据。在Acumatica中将文件附加到购买收据后,我似乎无法更新购买收据,并开始收到"Sequence Contains No Matching elements";错误。附加文件到购买收据会改变一些我不知道的东西吗?提前感谢您的任何帮助!

这是一个示例购买收据,我试图在附加一个小样本。txt文件到收据后更新

以下是发送给Acumatica的PUT请求正文示例,用于将收货数量更新为33(如果没有附加文件则确认工作,在文件附加后不工作):

{
"id": "d5c53b1c-0b06-ed11-8312-0a72f5e849b2",
"rowNumber": 1,
"note": {
"value": ""
},
"BaseCurrencyID": {
"value": "CAD"
},
"BillDate": {
"value": "2021-08-25T00:00:00+00:00"
},
"Branch": {
"value": "BOE"
},
"ControlQty": {
"value": 2.000000
},
"CreateBill": {
"value": false
},
"CurrencyEffectiveDate": {
"value": "2020-12-29T00:00:00+00:00"
},
"CurrencyID": {
"value": "CAD"
},
"CurrencyRate": {
"value": 1.00000000
},
"CurrencyRateTypeID": {},
"CurrencyReciprocalRate": {
"value": 1.00000000
},
"Date": {
"value": "2021-08-25T00:00:00+00:00"
},
"Details": [
{
"id": "d5c53b1c-0b06-ed11-8312-0a72f5e849b2",
"rowNumber": 1,
"note": {
"value": ""
},
"Account": {
"value": "5000"
},
"AccrualAccount": {
"value": "2000"
},
"AccrualSubaccount": {
"value": "000"
},
"Branch": {
"value": "BOE"
},
"Description": {
"value": "Cost of Purchase"
},
"EditableUnitCost": {
"value": true
},
"EstimatedINExtendedCost": {
"value": 312.0000
},
"ExtendedCost": {
"value": 312.0000
},
"FinalINExtendedCost": {},
"InventoryID": {
"value": "E10003"
},
"LineNbr": {
"value": 1
},
"LineType": {
"value": "Non-Stock"
},
"OpenQty": {
"value": 0.0
},
"OrderedQty": {
"value": 1.000000
},
"POLineNbr": {
"value": 1
},
"POOrderNbr": {
"value": "000003"
},
"POOrderType": {
"value": "Normal"
},
"POReceiptLineNbr": {},
"POReceiptNbr": {},
"ReceiptQty": {
"value": 33.000000
},
"Subaccount": {
"value": "000"
},
"TransactionDescription": {
"value": "Ladder - 24' Aluminum Extension Ladder"
},
"TransferOrderLineNbr": {},
"TransferOrderNbr": {},
"TransferOrderType": {},
"TransferShipmentNbr": {},
"UnitCost": {
"value": 22.0000
},
"UOM": {
"value": "EA"
},
"custom": {}
}
],
"Hold": {
"value": true
},
"Location": {
"value": "MAIN"
},
"PostPeriod": {
"value": "082021"
},
"ProcessReturnWithOriginalCost": {
"value": false
},
"ReceiptNbr": {
"value": "000138"
},
"Status": {
"value": "On Hold"
},
"TotalCost": {
"value": 213.0000
},
"TotalQty": {
"value": 2.000000
},
"Type": {
"value": "Receipt"
},
"UnbilledQuantity": {
"value": 2.000000
},
"VendorID": {
"value": "GROPWA"
},
"VendorRef": {},
"custom": {},
"files": [
{
"id": "6f621043-a8z4-4a89-b34f-910d399e31c0",
"filename": "Purchase Receipts (RT, 000138)\Sample.txt",
"href": "/entity/Purchasing/20.200.001/files/6f621043-a8z4-4a89-b34f-910d399e31c0"
}
]
}

下面是尝试更新后收到的错误响应:

{
"message": "An error has occurred.",
"exceptionMessage": "Sequence contains no matching element",
"exceptionType": "System.InvalidOperationException",
"stackTrace": "   at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source, Func`2 predicate)rn   at PX.Api.ContractBased.EntityExportContextBuilder.ExtractFieldMappingKeyForDetail(String mappingKey, EntityField field, EntityMappingProjection[] entityFields, IMetadataProvider metadataProvider, IEntityMappingKeyService entityMappingKeyService, String endpointName, String version)rn   at PX.Api.ContractBased.EntityExportContextBuilder.EntityFieldsOrderComparer.Compare(EntityField x, EntityField y)rn   at System.Linq.EnumerableSorter`2.CompareKeys(Int32 index1, Int32 index2)rn   at System.Linq.EnumerableSorter`1.QuickSort(Int32[] map, Int32 left, Int32 right)rn   at System.Linq.EnumerableSorter`1.Sort(TElement[] elements, Int32 count)rn   at System.Linq.OrderedEnumerable`1.<GetEnumerator>d__1.MoveNext()rn   at PX.Api.ContractBased.EntityExportContextBuilder.BuildPutCommands(EntityImpl entity, String mappingKey, Boolean newEntity, EntityMappingProjectionWrapper[] orderedMappedFields, ISet`1 preProcessedFields, Boolean isDetail)rn   at PX.Api.ContractBased.EntityExportContextBuilder.BuildContextForPutOrInvoke(EntityDescriptor descriptor, Boolean isNewEntity, Action`2 appendActionsDelegate)rn   at PX.Api.ContractBased.EntityService.Put(ISystemContract systemContract, String version, String name, EntityImpl entity, CbOperationContext operationContext, Boolean throwOnError)rn   at PX.Api.ContractBased.Soap.SoapFacadeBase.PutImpl(EntityImpl entity, Boolean throwOnValidationError)rn   at PX.Api.ContractBased.SystemContracts.V2.RestController.PutEntity(EntityImpl entity, String select, String filter, String expand, String custom)rn   at lambda_method(Closure , Object , Object[] )rn   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass6_2.<GetExecutor>b__2(Object instance, Object[] methodParameters)rn   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)rn--- End of stack trace from previous location where exception was thrown ---rn   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()rn   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)rn   at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__1.MoveNext()rn--- End of stack trace from previous location where exception was thrown ---rn   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()rn   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)rn   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__6.MoveNext()rn--- End of stack trace from previous location where exception was thrown ---rn   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()rn   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__6.MoveNext()rn--- End of stack trace from previous location where exception was thrown ---rn   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()rn   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)rn   at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__5.MoveNext()rn--- End of stack trace from previous location where exception was thrown ---rn   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()rn   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)rn   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__6.MoveNext()rn--- End of stack trace from previous location where exception was thrown ---rn   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()rn   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__6.MoveNext()rn--- End of stack trace from previous location where exception was thrown ---rn   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()rn   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)rn   at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__5.MoveNext()rn--- End of stack trace from previous location where exception was thrown ---rn   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()rn   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)rn   at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__5.MoveNext()rn--- End of stack trace from previous location where exception was thrown ---rn   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()rn   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)rn   at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__3.MoveNext()rn--- End of stack trace from previous location where exception was thrown ---rn   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()rn   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)rn   at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__6.MoveNext()rn--- End of stack trace from previous location where exception was thrown ---rn   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()rn   at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__6.MoveNext()rn--- End of stack trace from previous location where exception was thrown ---rn   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()rn   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)rn   at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__15.MoveNext()"
}

同意Samvel,单独请求。还可以使用下面的命令将流/文件推送到实体:

var response = _httpClient.PutAsync(_httpClient.BaseAddress + entityName + "/" + keys + "/files/" + fileName, new StreamContent(file)).Result;

我不确定您的请求有什么问题,但我建议您只发送您需要通过PUT请求更新的字段。

该错误似乎暗示您正在尝试更新无法找到的实体或子实体。这将意味着id GUID字段值或您正在发送的键字段值在系统中不存在。

有3个id字段,你可能想检查一下值是否仍然相同。

但是我再次强调,如果你不想更新一个字段,不要通过API发送它。这可能会解决你所面临的问题。

最新更新