Solved

Error updating existing record in Acumatica using API PUT

  • 24 May 2023
  • 7 replies
  • 165 views

Userlevel 1

I’m trying to update an existing stock item record using a PUT request:

 

but I’m getting the following "Object reference not set to an instance of an object." 500 error from the server. Why is this happening? I can retrieve the record just fine using a GET request.

{
"message": "An error has occurred.",
"exceptionMessage": "Operation failed",
"exceptionType": "PX.Data.PXInvalidOperationException",
"stackTrace": " 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()",
"innerException": {
"message": "An error has occurred.",
"exceptionMessage": "Object reference not set to an instance of an object.",
"exceptionType": "System.NullReferenceException",
"stackTrace": " at KN.CP.KNCPInventoryItemMaintExt.InventoryItem_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected BaseSelectedevent)\r\n at KN.DistrictCameras.KNDCInventoryItemMaintBaseExt.InventoryItem_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected BaseEvent)\r\n at KN.S3Images.KNCPInventoryItemMaintS3Ext.InventoryItem_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected BaseSelectedevent)\r\n at KNCommerceBasic.KNCBInventoryItemMaintExt.InventoryItem_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected BaseEvent)\r\n at KNMagentoConnector.KNMCInventoryItemMaintExtn.InventoryItem_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected BaseEvent)\r\n at PX.Data.PXRowSelected.Invoke(PXCache sender, PXRowSelectedEventArgs e)\r\n at PX.Data.PXCache.OnRowSelected(Object item)\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()"
}
}

 

icon

Best answer by pmblake 7 June 2023, 00:14

View original

7 replies

Userlevel 7
Badge +4

@pmblake 

You cant use filter with PUT.

You would need to pass inventoryID in body to update that stock item. See below:

Before
Postman update with inventoryID in body
Updated description using API

 

Userlevel 1

@pmblake

You cant use filter with PUT.

You would need to pass inventoryID in body to update that stock item. See below:

Before
Postman update with inventoryID in body
Updated description using API

 

 

Hi Rohit, I changed the request the following and I’m still getting the same error:

 

Userlevel 7
Badge +4

@pmblake 

Are you able to GET that inventory using POSTMAN?

Also, maybe try changing description it in the UI just to confirm/compare behavior with API?

Userlevel 1

@RohitRattan88 yes, that’s the weird part. I can GET the inventory ID record just fine, and change the title via UI as well:

 

Very confused as to why the PUT is not working

 

 

Userlevel 1

This ended up being a problem with a customization which was causing issues with the InventoryMaintenance. Thanks for your help @RohitRattan88 

Userlevel 7
Badge

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

Userlevel 7
Badge +4

This ended up being a problem with a customization which was causing issues with the InventoryMaintenance. Thanks for your help @RohitRattan88 

@pmblake  glad you were able to figure it out

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