Skip to main content
Solved

Error updating existing record in Acumatica using API PUT


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()"
    }
}

 

Best answer by pmblake

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

View original
Did this topic help you find an answer to your question?

7 replies

RohitRattan88
Acumatica Moderator
Forum|alt.badge.img+4
  • Acumatica Moderator
  • 245 replies
  • May 24, 2023

@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

 


  • Author
  • Freshman II
  • 6 replies
  • May 24, 2023
RohitRattan88 wrote:

@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:

 


RohitRattan88
Acumatica Moderator
Forum|alt.badge.img+4
  • Acumatica Moderator
  • 245 replies
  • May 25, 2023

@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?


  • Author
  • Freshman II
  • 6 replies
  • May 26, 2023

@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

 

 


  • Author
  • Freshman II
  • 6 replies
  • Answer
  • June 6, 2023

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


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • 2640 replies
  • June 7, 2023

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


RohitRattan88
Acumatica Moderator
Forum|alt.badge.img+4
  • Acumatica Moderator
  • 245 replies
  • June 7, 2023
pmblake wrote:

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings