Skip to main content
Solved

Sales Orders API giving 500 internal server error Status Code


abdallaahmed61
Varsity III
Forum|alt.badge.img+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

 

Best answer by abdallaahmed61

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

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

13 replies

darylbowman
Captain II
Forum|alt.badge.img+13

Could you post some more information about your request?


abdallaahmed61
Varsity III
Forum|alt.badge.img+1
darylbowman wrote:

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


darylbowman
Captain II
Forum|alt.badge.img+13

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.


abdallaahmed61
Varsity III
Forum|alt.badge.img+1
darylbowman wrote:

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 


anahizentella94
Jr Varsity III
Forum|alt.badge.img

Do you have to send Tax Details?

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


abdallaahmed61
Varsity III
Forum|alt.badge.img+1
anahizentella94 wrote:

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


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

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


abdallaahmed61
Varsity III
Forum|alt.badge.img+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


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

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.


abdallaahmed61
Varsity III
Forum|alt.badge.img+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 


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

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

 


abdallaahmed61
Varsity III
Forum|alt.badge.img+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 

 


abdallaahmed61
Varsity III
Forum|alt.badge.img+1
  • Author
  • Varsity III
  • 53 replies
  • Answer
  • August 20, 2023

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


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