Solved

Sales Orders API giving 500 internal server error Status Code


Userlevel 3
Badge +1

When i call Sales Orders API and put the data in the body when i execute the Request 

i Get 500 Status code with 

"exceptionMessage":"Object reference not set to an instance of an object."

but when i put the same data manually the order saves normally.

anyone faced this problem before ?

Below is the Stack

Stack Trace For http://Websiteserver/siteName/entity/Integration/18.200.001/SalesOrder

 

icon

Best answer by abdallaahmed61 20 August 2023, 16:21

View original

13 replies

Badge +11

Could you post some more information about your request?

Userlevel 3
Badge +1

Could you post some more information about your request?

{
"OrderNbr": {
"value": "09959312"
},
"OrderType": {
"value": "TC"
},
"CustomerID": {
"value": "3539033"
},
"PaymentRef": {
"value": "1010"
},
"ClientName": {
"value": "Yomna Gaber"
},
"Details": [
{
"Branch": {
"value": "00002"
},
"InventoryID": {
"value": "100528051"
},
"WarehouseID": {
"value": "03"
},
"OrderQty": {
"value": 1.00
},
"UnitPrice": {
"value": 100.00
}
}
],
"FinancialSettings": {
"InvoiceNbr": {
"value": "T12364133"
}
},
"TaxDetails": [
{
"TaxID": {
"value": "VATS"
}
}
]
}

this is my request body, when i remove some elements and remove ordernbr for example and send request i get 500 but with error information that some fields are missing then i return the deleted data and send the request again it gives me 200 status code with order created is this a bug in acumatica ?!

Badge +11

In most situations I’ve seen, Order Nbr is auto-generated for new orders in the UI. Do you know if this is the case? I would expect you wouldn’t want to pass the Order Nbr if it auto-generates. Also, in the UI, it’s important to enter the Order Type before the Order Nbr. I don’t know if that matters in the API, but it could be something to try.

Userlevel 3
Badge +1

In most situations I’ve seen, Order Nbr is auto-generated for new orders in the UI. Do you know if this is the case? I would expect you wouldn’t want to pass the Order Nbr if it auto-generates. Also, in the UI, it’s important to enter the Order Type before the Order Nbr. I don’t know if that matters in the API, but it could be something to try.

In My instance configuration i must enter the orderNbr for business purpose.

i dont think the order of the fields will matter 

Userlevel 4
Badge

Do you have to send Tax Details?

The system calculates the taxes when you send the TaxCategoryID in SOLine object.

Userlevel 3
Badge +1

Do you have to send Tax Details?

The system calculates the taxes when you send the TaxCategoryID in SOLine object.

im just sending the type of the tax because we have alot of tax types

i deleted it but i got the same error

Userlevel 7
Badge +4

@anahizentella94 

Additional details would help to better understand the issue and provide suggestions:

Site built number
Endpoint seems to be custom(maybe provide screenshots for your endpoint to make sure it is properly defined)
full Error message in text format for better review

 

I would start with minimum necessary payload(SO Header and Line, maybe just Header to begin with) to narrow down the issue.

Userlevel 3
Badge +1

if you want to check the data from the site we can enter a meeting.

because i cant share the company data for everyone

Userlevel 7
Badge +4

do you have a test instance?
How is the behavior if you test it on a local instance?

Maybe hide/blackout the sensitive data but provide the process/error information.

Userlevel 3
Badge +1

Check the video 

first request i sent it normally => gave 500 status code

second request after deleting some fields finally gave me another error

at the end i sent the same request with almost the same data and the request excueted normally

i must make these steps every time so that the request works 

Userlevel 7
Badge +4

you could search and troubleshoot the response error message on what in your payload is causing the issue. One of the errors in the video was that ClientName not found in system.

As suggested before, start with minimum required fields and add more fields to narrow down the issue.

Here’s how I created a simple SO using REST:

POSTMAN call

Result in UI:

Resulting Order
{
"CustomerID": {
"value": "AACUSTOMER"
},
"Date": {
"value": "2022-07-44"
},
"Description": {
"value": "Test order API"
},
"Details": [
{
"Branch": {
"value": "PRODWHOLE"
},
"InventoryID": {
"value": "AACOMPUT01"
},
"LineDescription": {
"value": "Acer Laptop Computer"
},
"OrderQty": {
"value": 50.000000
}
}
],
"LocationID": {
"value": "MAIN"
},
"OrderType": {
"value": "BL"
}
}

 

Userlevel 3
Badge +1

the client isnt found becasue i was sending request to the live website and this client isnt available there but the problem is that you need to send an invalid body with missing fields first then send the full bdy in another request 

 

Userlevel 3
Badge +1

i solved the problem by sending a fake request after getting the token which will give me status code 500

after this the api works normally

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