Skip to main content
Question

Error during the payment updаte via API

  • August 30, 2022
  • 7 replies
  • 410 views

Forum|alt.badge.img

Hello Team,

I found the following error with payments.

1. I have created a payment via API. The payment is being created successfully.
2. Then I use a payment to allocate with invoice or credit memo via API to pay it.
3. Send the payment with allocation to the invoice or credit memo to Acumatica via API.

Acumatica returns the following error message:

Payment update request returns the error message - "exceptionMessage": "An error occurred during processing of the field Reference Nbr.: Reference Nbr. 'AR.......' cannot be found in the system.\nPX.Data.PXOuterException: An error occurred during processing of the field Reference Nbr.: Reference Nbr. 'AR......' cannot be found in the system."

When I repeat the same Payment update request after a period of time (in 1,5,10,20 minutes), Acumatica creates a payment successfully.

Could you clarify what is the reason of this behavior?

7 replies

Forum|alt.badge.img+5
  • Semi-Pro III
  • August 30, 2022

@Andrew1986 Can you clarify what solution you are using exactly? Did you create this API integration yourself, or is it an out-of-the-box integration?

The API is throwing an error that you are not populating the ReferenceNbr field correctly. Since you are updating the record, you need to provide a correct primary key field for the system to know what record to update. It looks like your Reference Number is literally: AR...…

So maybe this was some stub code where the correct concatenation isn’t in there yet to properly populate the field?


Forum|alt.badge.img
  • Author
  • Freshman I
  • August 30, 2022

We use our integration.
I mean that our connector uses API calls to receive data.

As for the error message, here the real example of the error message:

"innerException":{"message":"An error has occurred.","exceptionMessage":"An error occurred during processing of the field Reference Nbr.: Reference Nbr. 'AR006170' cannot be found in the system.","exceptionType":"PX.Data.PXFieldProcessingException","stackTrace":"   at PX.Data.SessionRollback.ProcessUpdateException[ExceptionType](ExceptionType ex, PXCache cache, IDictionary keys, IDictionary values)\r\n 

It means that we created the allocation between payment and Invoice AR006170.
When we sent this request firstly, we received this error message presented above.
But during the second attempt in a few minutes, Acumatica returned the successful answer that payment with allocation to the invoice AR006170 was created.

 


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • October 31, 2022

Hi @Andrew1986 - did you find a solution for this one? Thank you!


  • Freshman I
  • August 26, 2026

Anyone got the solution to this ?


Forum|alt.badge.img+5
  • Semi-Pro III
  • August 26, 2026

This sounds like a race condition. The Acumatica API can be a bit slow. I’d try waiting longer between the creation of the payment record and the linking to the invoice, for example.


  • Freshman I
  • September 5, 2026

Hi, I tried this in a sandbox, and I was the only API user at the moment, and it was still giving this error, despite trying after some time, I am not sure if any different payload format that can be used to bypass this issue .

See below payloads - Create payment header:

{
"CustomerID": { "value": "CUST000003" },
"PaymentAmount": { "value": "5000.00" },
"PaymentMethod": { "value": "MPESA" },
"Type": { "value": "Payment" },
"PaymentRef": { "value": "{{payment_ref}}" },
"BranchID": { "value": "NAKURU" },
"CashAccount": { "value": "80107" },
"Description": { "value": "Payment Confirmed by Safaricom" }
}

Apply payment to invoice:

{
"Type": { "value": "Payment" },
"ReferenceNbr": { "value": "RC1856272" },
"DocumentsToApply": [
{
"DocType": { "value": "Invoice" },
"ReferenceNbr": { "value": "IN1778602" },
"AmountPaid": { "value": "5000.00" }
}
]
}

Response :

{
"message": "An error has occurred.",
"exceptionMessage": "An error occurred during processing of the field Reference Nbr.: Reference Nbr. 'IN1778602' cannot be found in the system.\nPX.Data.PXOuterException: An error occurred during processing of the field Reference Nbr.: Reference Nbr. 'IN1778602' cannot be found in the system.",
"exceptionType": "PX.Api.ContractBased.OutcomeEntityHasErrorsException",
"stackTrace": " at System.Monads.ArgumentCheck.CheckNull[TSource](TSource source, Func`1 exceptionSource)\r\n at PX.Api.ContractBased.EntityService.GetOperationResult(EntityImpl entity, EntityExportContextBuilder entityExportContextBuilder, PXSYTable exportedKeys, PXOuterException contextError, Boolean throwOnError, Boolean addCancelCommand)\r\n at PX.Api.ContractBased.EntityService.CreateOrUpdate(ISystemContract systemContract, String version, String name, EntityImpl entity, CbOperationContext operationContext, Boolean throwOnError, Boolean isPatch)\r\n at PX.Api.ContractBased.EntityService.Put(ISystemContract systemContract, String version, String name, EntityImpl entity, CbOperationContext operationContext, Boolean throwOnError)\r\n at PX.Api.ContractBased.AspNetCore.CbEndpointFeatureServiceExtensions.Put(IEntityService entityService, ICbEndpointFeature feature, EntityImpl entity, CbOperationContext operationContext)\r\n at PX.Api.ContractBased.WebApi.Controllers.EntityController.PutEntity(EntityImpl entity, String select, String filter, String expand, String custom)\r\n at lambda_method(Closure , Object , Object[] )\r\n at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)\r\n at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeActionMethodAsync>d__12.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 Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeNextActionFilterAsync>d__10.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 Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)\r\n at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)\r\n at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeInnerFilterAsync>d__13.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 Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeNextExceptionFilterAsync>d__24.MoveNext()"
}

This occurs despite of having an open invoice with that ref number in the system


harutyungevorgyan
Jr Varsity I
Forum|alt.badge.img+4

Hi ​@Andrew1986 ,

The ReferenceNbr in DocumentsToApply is a selector. It lists only documents that can be applied at that moment: open, released, with a balance, for that customer (or its related accounts when balances are consolidated), and of the DocType you send. "Cannot be found in the system" means the invoice wasn't on that list when the request ran.

The retry succeeding 1–20 minutes later points to one cause: the invoice's release hadn't finished. Releasing through REST (POST .../Invoice/ReleaseInvoice) returns 202 Accepted with a Location header, and the release keeps running in the background. Until it completes, the invoice is still Balanced, not Open, so the payment can't select it. Wait for the release before you apply using the Location value you received as a response. When the GET HTTP method with this URL returns 204 No Content, the operation is completed..

If the error happens every time (JohnKihiu's sandbox case), check the invoice directly with GET:

  • Status must be Open, not On Hold or Balanced.
  • CustomerID must match the payment's customer (CUST000003) or be a child account with a consolidated balance.
  • The invoice's branch must belong to the same company as the payment's branch, and the API user must have access to that branch.
  • DocType must match: "Invoice" vs "Debit Memo" vs "Credit Memo".