Skip to main content
Solved

Unable to update record using Restful API

  • September 4, 2023
  • 4 replies
  • 378 views

Michael Ndungi
Varsity I
Forum|alt.badge.img


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

Best answer by jinin

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

 

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

4 replies

jinin
Pro I
Forum|alt.badge.img+11
  • Pro I
  • 701 replies
  • September 4, 2023

Hi @Michael Ndungi 

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

 


Michael Ndungi
Varsity I
Forum|alt.badge.img

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

 

 


jinin
Pro I
Forum|alt.badge.img+11
  • Pro I
  • 701 replies
  • Answer
  • September 4, 2023

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

 


Michael Ndungi
Varsity I
Forum|alt.badge.img

Thank you so much @jinin 


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