Skip to main content

Hi,

I would like to ask for some insight on this API request error, if there is any available work around or fix.

 

Create Bill causes error Subaccount cannot be empty. Inserting  'AP Transactions' record raised at least one error. Please review the errors.

 

Customization: none

version 23R1

endpoint: Default/18.200.001

{
    "message": "An error has occurred.",
    "exceptionMessage": "Bill.Details.0].Account: Account is inactive.\nBill.Details.0].Subaccount: 'Subaccount' cannot be empty.\nInserting  'AP Transactions' record raised at least one error. Please review the errors.",
    "exceptionType": "PX.Api.ContractBased.OutcomeEntityHasErrorsException",
    "stackTrace": "   at PX.Api.ContractBased.EntityService.GetOperationResult(EntityImpl entity, EntityExportContextBuilder entityExportContextBuilder, PXSYTable exportedKeys, PXOuterException contextError, Boolean throwOnError, Boolean addCancelCommand) in C:\\build\\code_repo\\NetTools\\PX.Api.ContractBased\\EntityService.cs:line 724\r\n   at PX.Api.ContractBased.EntityService.Put(ISystemContract systemContract, String version, String name, EntityImpl entity, CbOperationContext operationContext, Boolean throwOnError) in C:\\build\\code_repo\\NetTools\\PX.Api.ContractBased\\EntityService.cs:line 676\r\n   at PX.Api.ContractBased.Soap.SoapFacadeBase.PutImpl(EntityImpl entity, Boolean throwOnValidationError) in C:\\build\\code_repo\\NetTools\\PX.Api.ContractBased\\Soap\\SoapFacadeBase.cs:line 126\r\n   at PX.Api.ContractBased.SystemContracts.V2.RestController.PutEntity(EntityImpl entity, String select, String filter, String expand, String custom) in C:\\build\\code_repo\\NetTools\\PX.Api.ContractBased\\SystemContracts\\V2\\RestController.cs:line 304\r\n   at lambda_method(Closure , Object , Object ] )\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass6_2.<GetExecutor>b__2(Object instance, Objectc] methodParameters)\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__1.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 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__6.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 System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__6.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 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__5.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 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__6.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 System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__6.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 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__5.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 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__5.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 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__3.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 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__6.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 System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__6.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 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__15.MoveNext()"
}

 

endpoint: Default/20.200.001 and Default/22.200.001

 

Have you tried manually creating the Bill with the same details as what is in the API. 

Can you share the API details of what you are posting

 


Hi @dcomerford 

 

Creating the Bill manually via UI has no error, below is the sample json details.

 

{
  "Amount": {
    "value": 3788.40
  },
  "Branch": {
    "value": "XTL1"
  },
  "Type": {
    "value": "INV"
  },
  "Date": {
    "value": "2024-06-20"
  },
  "VendorRef": {
    "value": "CI0017562"
  },
  "Vendor": {
    "value": "MDL001"
  },
  "Description": {
    "value": "CLAIM-97927"
  },
  "PostPeriod": {
    "value": "032025"
  },
  "Document": {
    "value": "http://localhost:25430/expense/edit_link.go?expenseId=908561"
  },
  "TaxCalculationMode": {
    "value": "Gross"
  },
  "Details": l
    {
      "TransactionDescription": {
        "value": "Legal Fees to recover Grower Debt"
      },
      "TransactionDescr": {
        "value": "Legal Fees to recover Grower Debt"
      },
      "Quantity": {
        "value": "1.00"
      },
      "ExpenseDate": {
        "value": "2024-06-20"
      },
      "POReceiptNbr": {
        "value": "045394"
      },
      "POReceiptLine": {
        "value": 1
      },
      "UnitCost": {
        "value": "3788.4000"
      },
      "TaxCategory": {
        "value": "DEFAULTD"
      },
      "Branch": {
        "value": "XTL1"
      },
      "Project": {
        "value": "X"
      },
      "InventoryId": {
        "value": "PNMGR"
      }
    }
  ]
}


@jessieparas Can you put the fields in the Order you would input them if you did it manually.


Hi @jessieparas ,

I reviewed the request and found that the Type is set to 'INV'. It should be 'Bill'. I’ve shared a sample JSON request. Please review it.

{

  "VendorRef": {

    "value": "12"

  },

  "Description": {

    "value": "docAlpha BatchID \"1008\""

  },

  "Vendor": {

    "value": "0000002346"

  },

  "Date": {

    "value": "12/03/2021"

  },

  "Hold": { "value": false },

  

  "PostPeriod": {

    "value": "12-2021"

  },

  "Type": {

    "value": "Bill"

  },

  "Details": a

    {

      "InventoryID": {

        "value": "321"

      },

      "Description": {

        "value": "123"

      },

      "Branch": {

        "value": "TIGER"

      },

      "POOrderNbr": {

        "value": "PO00987543"

      },

      "POReceiptNbr": {

        "value": "054300"

      },

      "UOM": {

        "value": "EA"

      },

      "ExtendedCost": {

        "value": "117.51"

      },

      "Qty": {

        "value": "1.0"

      },

      "UnitCost": {

        "value": "117.51"

      },

       "POReceiptLine": {

        "value": "1"

      },

      "rowNumber": {

        "value": "1"

      }

    }

  ]

}


Hi @jinin and @dcomerford 

 

I have figured out the the cause and it is because the Subaccount feature is enable that is why the Subaccount entity is required on the request. In order to fix, Subaccount entity must be included on the json body. Thank you for looking up the question that I raised, I appreciate it so much.

 

 

 


Thank you for sharing your solution with the community @jessieparas!


Reply