Skip to main content
Solved

Help needed with CreateAPBill action via API from Purchase Receipt

  • May 29, 2025
  • 7 replies
  • 170 views

adriangavino45
Freshman I
Forum|alt.badge.img

Hi everyone,

I’m currently trying to create an AP Bill from a Purchase Receipt using an API (Postman), but I’m running into an error.

Here are the details:

Endpoint:
 

POST {{BaseURL}}/entity/Default/23.200.001/PurchaseReceipt/CreateAPBill

 

Request Body:

{
"entity":
{
"id":
"a256ce42-5b3b-f011-837f-0eddcec71d29"
}
}

Response from Postman:

{
"message": "An error has occurred.",
"exceptionMessage": "Operation failed",
"exceptionType": "PX.Data.PXInvalidOperationException",
"stackTrace": " at PX.Api.ContractBased.EntityService.Invoke(ISystemContract systemContract, String version, String name, EntityImpl entity, ActionImpl action, CbOperationContext operationContext, Boolean throwOnError)\r\n at PX.Api.ContractBased.AspNetCore.CbEndpointFeatureServiceExtensions.Invoke(IEntityService entityService, ICbEndpointFeature feature, EntityImpl entity, ActionImpl action, CbOperationContext operationContext)\r\n at PX.Api.ContractBased.WebApi.Controllers.ActionController.InvokeAction(String objectName, String actionName, ActionInvocation invocation)\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()",
"innerException": {
"message": "An error has occurred.",
"exceptionMessage": "Enter AP Bill",
"exceptionType": "PX.Data.PXRedirectRequiredException",
"stackTrace": " at PX.Objects.PO.POReceiptEntry.CreateAPDocument(PXAdapter adapter)\r\n at PX.Data.PXAction`1.RunHandler(PXAdapter adapter)\r\n at PX.Data.PXAction`1.<Press>d__39.MoveNext()\r\n at PX.Data.PXAction`1.<Press>d__39.MoveNext()\r\n at PX.Api.SyImportProcessor.SyStep.PressButton(PXAction button, PXAdapter adapter, SyView view, String actionName, Object[] currents)\r\n at PX.Api.SyImportProcessor.SyStep.CommitChangesInt(Object itemToBypass, PXFilterRow[] targetConditions, PXFilterRow[] filtersForAction, SyImportRowResult importResult)\r\n at PX.Api.SyImportProcessor.SyStep.CommitChanges(Object& itemToBypass, PXFilterRow[] targetConditions, PXFilterRow[] filtersForAction)\r\n at PX.Api.SyImportProcessor.ExportTableHelper.ExportTable(CancellationToken token)"
}
}

 

It seems to be failing with a PXRedirectRequiredException and the message "Enter AP Bill".

I’m following the process shown in this video (minute 48:00):
https://www.youtube.com/watch?v=WZjlfsN6aew

 

Has anyone tried this before? Do you have any recommendations or examples of a successful implementation of CreateAPBill through the API?

Any help or guidance would be greatly appreciated!

Thank you in advance.


Best regards,

Best answer by Vignesh Ponnusamy

Hi ​@adriangavino45,

Following this community posted, we checked with our engineering team and below are the details,

As you can notice, when you create an AP Bill for a Purchase Receipt using the Enter AP Bill action, it enters the AP Bill but doesn’t not save the AP Bill and the user has to save the AP Bill. So by default the document remains unsaved which is leads to this behavior. 

In this case, using API you can directly create an AP Bill for a Purchase Receipt like below,

{
"BranchID": {
"value": "PRODWHOLE"
},
"CurrencyID": {
"value": "USD"
},
"Date": {
"value": "2025-06-12T00:00:00-04:00"
},
"Details": [
{
"POReceiptLine": {
"value": 1
},
"POReceiptNbr": {
"value": "PR002078"
},
"POReceiptType": {
"value": "Receipt"
}
}
],
"Hold": {
"value": true
},
"LocationID": {
"value": "MAIN"
},
"PostPeriod": {
"value": "062025"
},
"Type": {
"value": "Bill"
},
"Vendor": {
"value": "AASERVICES"
},
"VendorRef": {
"value": "Test"
}
}

Note: POReceiptType and POReceiptNbr should be provided in the Details entity to ensure the PO and AP are linked correctly. All lines of the Purchase Receipt will be added to the AP Bill in this case.
The POReceiptLine can be used if specific lines of the Purchase Receipt need to be added to the AP Bill.

To avoid the confusion/error our engineering decided to remove the CreateAPBill action from the default endpoint in the future versions. 

Please let us know if you have any follow-up questions!

cc: ​@Dmitrii Naumov 

7 replies

Dmitrii Naumov
Acumatica Moderator
Forum|alt.badge.img+7
  • Acumatica Moderator
  • May 29, 2025

Seems to be a bug. We’ll investigate.


adriangavino45
Freshman I
Forum|alt.badge.img

Hi ​@Dmitrii Naumov,

Thanks!

Regards.


Vignesh Ponnusamy
Acumatica Moderator
Forum|alt.badge.img+5

Hi ​@adriangavino45,

Following this community posted, we checked with our engineering team and below are the details,

As you can notice, when you create an AP Bill for a Purchase Receipt using the Enter AP Bill action, it enters the AP Bill but doesn’t not save the AP Bill and the user has to save the AP Bill. So by default the document remains unsaved which is leads to this behavior. 

In this case, using API you can directly create an AP Bill for a Purchase Receipt like below,

{
"BranchID": {
"value": "PRODWHOLE"
},
"CurrencyID": {
"value": "USD"
},
"Date": {
"value": "2025-06-12T00:00:00-04:00"
},
"Details": [
{
"POReceiptLine": {
"value": 1
},
"POReceiptNbr": {
"value": "PR002078"
},
"POReceiptType": {
"value": "Receipt"
}
}
],
"Hold": {
"value": true
},
"LocationID": {
"value": "MAIN"
},
"PostPeriod": {
"value": "062025"
},
"Type": {
"value": "Bill"
},
"Vendor": {
"value": "AASERVICES"
},
"VendorRef": {
"value": "Test"
}
}

Note: POReceiptType and POReceiptNbr should be provided in the Details entity to ensure the PO and AP are linked correctly. All lines of the Purchase Receipt will be added to the AP Bill in this case.
The POReceiptLine can be used if specific lines of the Purchase Receipt need to be added to the AP Bill.

To avoid the confusion/error our engineering decided to remove the CreateAPBill action from the default endpoint in the future versions. 

Please let us know if you have any follow-up questions!

cc: ​@Dmitrii Naumov 


adriangavino45
Freshman I
Forum|alt.badge.img

Hi ​@Vignesh Ponnusamy  
Thank you for the detailed explanation and for checking with the engineering team.

I’ll proceed with the testing using the structure you provided and will share the results shortly.

I’ll keep you posted!

Best regards,


adriangavino45
Freshman I
Forum|alt.badge.img

Hi ​@Vignesh Ponnusamy,

I tried to do the process as you indicated, however I get this response.

{
"message": "The request is invalid.",
"modelState": {
"entity": [
"The Entity field is required."
]
}
}

This is the image:
 

 

Thanks,

Regards.


Vignesh Ponnusamy
Acumatica Moderator
Forum|alt.badge.img+5

Hi ​@adriangavino45,

Couple of suggestions here,

  • Use entity/Default/23.200.001/Bill in the Request URL
  • As we are attempting to create a Bill directly by linking the PO Receipt, do a PUT request and not POST request

Hope that helps, please feel free to post back if you have any questions.


adriangavino45
Freshman I
Forum|alt.badge.img

Thanks ​@Vignesh Ponnusamy it works!

Regards,