Rank: Member
Groups: Registered
Joined: 3/21/2024(UTC) Posts: 15 
|
When I POST a SalesItem it fails because returnsAndAllowancesAccountId is not specified, despite it being specified in the request. I have done this through the application we're developing and through the Swagger UI that's available with the REST service. We have tried different forms of capitalization and cannot seem to get it to work.
Below is my account request to get an account id that I then supply in the POST SalesItem request and ultimately get a failure response (all seen below).
I am running CenterPoint Accounting 19.9.30.
ACCT GET REQUEST: curl -X 'GET' \ 'http://localhost:54459/api/centerpoint/accounts?number=403000' \ -H 'accept: text/plain' \ -H 'Database: NutritionServices'
ACCT RESPONSE: [ { "id": 2147469967, "abbreviation": "", "name": "Returns & Allowances", "number": "403000", "type": "Revenue", "category": "Sales Revenue" } ]
SALESITEM POST REQUEST curl -X 'POST' \ 'http://localhost:54459/api/centerpoint/salesItems' \ -H 'accept: text/plain' \ -H 'Database: NutritionServices' \ -H 'Content-Type: application/json' \ -d '{ "abbreviation": "774", "name": "AUREO 100", "active": true, "expenseAccountId": 2147469993, "additionalDescription": "AUREO 100", "salesAccountId": 2147469965, "salesCategoryId": 2147469999, "returnsAndAllowancesAccountId": 2147469967 }'
SALESITEM POST RESPONSE: { "message": "Invalid Request", "errors": [ { "key": "SalesItemModel.ReturnsAndAllowancesAccountId", "message": "You must have a returns & allowances account before you can continue" } ] }
|
|
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 2/28/2018(UTC) Posts: 80  Location: Pennsylvani mostly Was thanked: 9 time(s) in 9 post(s)
|
Ah, sorry.
Set the templateId to an existing inventory item's ID which ensures that all the required information is set. Some people create items in CenterPoint for this purpose because it greatly speeds up the process of manually adding an item. If you have a mix of non-tracked/service and tracked items, then you need a different templateId for each.
The goal was something very simple, but the simplicity requires a templateId (which should be marked as required but is not.)
|
|
|
|
|
|
Rank: Member
Groups: Registered
Joined: 3/21/2024(UTC) Posts: 15 
|
Thank, Tony. We will try using the templateId property instead of explicitly setting each of those account and category properties. For our application that should work just fine.
I'm guessing if we did specify those properties that it would use our specified values instead of the template's values for those properties?
|
|
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 2/28/2018(UTC) Posts: 80  Location: Pennsylvani mostly Was thanked: 9 time(s) in 9 post(s)
|
Yes, the template item provides a starting point only.
|
|
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 12/4/2025(UTC) Posts: 2 
|
When I try to POST this to the /api/centerpoint/salesItems endpoint
{ "abbreviation": "6696e312f7469df7473337b6", "active": true, "expenseAccountId": 2147469938, "name": "1.25\" X 3.00\" X 4.50\"", "salesAccountId": 2147469938, "templateId": 2147469999 }
I get this
{ "message": "Invalid Request", "errors": [ { "key": "ApiError", "message": "Object reference not set to an instance of an object." } ] }
Not really clear what is going on. It seems the same error happens with the vendor endpoint but don't have an example of that yet.
|
|
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 2/28/2018(UTC) Posts: 80  Location: Pennsylvani mostly Was thanked: 9 time(s) in 9 post(s)
|
Much to my surprise, I tried the POST out with the exact Request Body against our BusinessSample database and it worked. I thought at least one of the foreign key IDs would be invalid.
That doesn't tell us much except that it's not some unlikely error like the abbreviation being too long or double quotes being a problem.
I'm not sure where to go from here though. Is this happening on every item you try to add or just this one specifically? And if you try the same POST again does it work? If you have some work and some not, then can you show me the Request Body for a POST that worked?
The fact that adding a vendor sometimes fails too potentially points to something outside the Sales Item infrastructure, but I'm not sure what. I'll think about this some more.
|
|
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 12/4/2025(UTC) Posts: 2 
|
For example, this was a success in production but it is not for me when testing locally:
{ "abbreviation": "68c858eeb15acba1685a2b50", "active": true, "expenseAccountId": 2147469770, "name": "ST3M761V3N3", "salesAccountId": 2147469938, "templateId": 2147469999 }
This does not work even when removed the double quotes:
{ "abbreviation": "6696e312f7469df7473337b6", "active": true, "expenseAccountId": 2147469938, "name": "X 4.5", "salesAccountId": 2147469938, "templateId": 2147469999 }
As I said, it seems very random but if a specific payload fails, it will never go through - it always fails - so repeated requests don't solve the problem.
As long as we can get some reasonable message telling us what is actually wrong - that would be ok. We can work with that. In this case, just the object reference/null error means it is the global error handler that caught the error and we can't really do anything except guessing...
|
|
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The Red Wing Software Developer Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close