Solved

Unable to update record using Restful API

  • 4 September 2023
  • 4 replies
  • 193 views

Userlevel 4
Badge


Hello everyone,

I extended  an endpoint for point of sale, I am able to fetch the data that I need very well from postman
see below.
 

However, when I try to update any detail , I get the following error,
see below how I’m trying to update line description to “TEST”

 

I get the above/following error

{
"message": "An error has occurred.",
"exceptionMessage": "Unable to cast object of type 'PX.Data.PXResult`2[IGFS.DAC.IGFSQuickOrder,PX.Objects.AR.Customer]' to type 'IGFS.DAC.IGFSQuickOrder'.",
"exceptionType": "System.InvalidCastException",
"stackTrace": " at PX.Data.Events.FieldSelecting`2.get_Row()\r\n at IGFS.GraphExtensions.IGFSCreatePaymentExt._(FieldSelecting`2 e)\r\n at PX.Data.PXFieldSelecting.Invoke(PXCache sender, PXFieldSelectingEventArgs args)\r\n at PX.Data.PXCache.OnFieldSelecting(String name, Object row, Object& returnValue, Boolean forceState, Boolean externalCall)\r\n at PX.Data.PXCache.RaiseFieldSelecting(String name, Object row, Object& returnValue, Boolean forceState)\r\n at PX.Api.SyImportProcessor.SyStep.EnumFieldValues(PXGraph graph, String viewName, String fieldName, PXFilterRow[] filters, Int32 topCount, String primaryViewName, Boolean ignoreStart)\r\n at PX.Api.SyImportProcessor.ExportTableHelper.EmitExportedRows(SyStep step, IGrowingTable table, SyCommand command, PXFilterRow[] filters, Int32 topCount)\r\n at PX.Api.SyImportProcessor.ExportTableHelper.ExportTable()\r\n at PX.Api.ContractBased.ExportTableHelperExtensions.RunExportAndAssertSuccess(SyExportContext exportContext)\r\n at PX.Api.ContractBased.EntityService.GetList(ISystemContract systemContract, String version, String name, EntityImpl entity, CbOperationContext operationContext, Boolean ignoreValueFields, PXGraph graph)\r\n at PX.Api.ContractBased.EntityService.GetImpl(ISystemContract systemContract, String version, String name, EntityImpl entity, EntityExportContextBuilder entityExportContextBuilder, EntityDescriptor entityDescriptor, CbOperationContext operationContext)\r\n at PX.Api.ContractBased.EntityService.DetermineEntityDescriptor(ISystemContract systemContract, String version, String name, EntityImpl entity, EntityExportContextBuilder entityExportContextBuilder, EntityDescriptor& entityDescriptor, PXGraph graph, CbOperationContext operationContext)\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.Soap.SoapFacadeBase.PutImpl(EntityImpl entity, Boolean throwOnValidationError)\r\n at PX.Api.ContractBased.SystemContracts.V2.RestController.PutEntity(EntityImpl entity, String select, String filter, String expand, String custom)\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, Object[] 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()"
}


Kindly assist
Any kind of response will be highly appreciated
 

Thank you all

icon

Best answer by jinin 4 September 2023, 12:19

View original

4 replies

Userlevel 7
Badge +11

Hi @Michael Ndungi 

As per the log, you are getting issues with the customization package. Unpublish the package and try again.
 

 

Userlevel 4
Badge

oh! its working now after addition of more details to the object I want to update

 

 

Userlevel 7
Badge +11

Hi @Michael Ndungi ,

Refer to the sample JSON to update the SOOrder through an API call.

{
"OrderNbr": {
"value": "SO1345" // Is using Manual order number, provide the value else not required this field.
},
"OrderType": {
"value": "SO"
},
"CustomerID": {
"value": "0009426360"
},
"note": "",
"CustomerOrder": {
"value": "11186462"
},
"Details": [
{
"note": "",
"InventoryID": {
"value": "07252"
},
"OrderQty": {
"value": "1.0000"
},
"ManualPrice": {
"value": true
},
"UnitPrice": {
"value": 39.95
},
"ManualDIscount": {
"value": true
},
"DiscountAmount": {
"value": 0
},
"TaxCategory": {
"value": "TAXABLE"
},
}
],
"ShipToAddressOverride": {
"value": true
},
"ShipToAddress": {
"AddressLine1": {
"value": " Maricopa Street"
},
"AddressLine2": {
"value": ""
},
"City": {
"value": "Torrance"
},
"State": {
"value": "CA"
},
"PostalCode": {
"value": "90506"
},
"Country": {
"value": "US"
}
},
"ShipToContactOverride": {
"value": true
},
"ShipToContact": {
"Attention": {
"value": null
},
"BusinessName": {
"value": "Robinson"
},
"Email": {
"value": "test@band.con"
},
"Phone1": {
"value": "555-555-5555"
}
},
"BillToAddressOverride": {
"value": true
},
"BillToAddress": {
"AddressLine1": {
"value": "Maricopa Street"
},
"AddressLine2": {
"value": ""
},
"City": {
"value": "Torrance"
},
"State": {
"value": "CA"
},
"PostalCode": {
"value": "90506"
},
"Country": {
"value": "US"
}
},
"BillToContactOverride": {
"value": true
},
"BillToContact": {
"Attention": {
"value": null
},
"BusinessName": {
"value": "Robinson"
},
"Email": {
"value": "test@band.con"
},
"Phone1": {
"value": "555-555-5555"
}
},
"PaymentMethod": {
"value": "CHECK"
},
"CashAccount": {
"value": "1001"
},
"ShipVia": {
"value": "LOCAL"
},
"Totals": {
"PremiumFreight": {
"value": "0.0000"
}
},
"FinancialSettings": {
"OverrideTaxZone": {
"value": true
},
"CustomerTaxZone": {
"value": "VERTEX"
}
},
"Payments": [
{
"ApplicationDate": {
"value": "2023-02-01"
},
"AppliedToOrder": {
"value": "43.9500"
},
"CashAccount": {
"value": "1063"
},
"PaymentAmount": {
"value": "43.9500"
},
"PaymentMethod": {
"value": "CHECK"
},
"PaymentRef": {
"value": "kjhk2kx19sgp"
}
}
],
"ShipByDate": {
"value": "2023-02-01"
},
"OrderPlacedDate": {
"value": "2023-02-01"
},
"OrderPlacedTime": {
"value": "2023-02-01 07:36:10"
},
"Description": {
"value": "TEST"
},
"ExternalRef": {
"value": "Website"
}
}

 

Userlevel 4
Badge

Thank you so much @jinin 

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved