Reputation: 31
The Branch field is present in the JSON, but Acumatica ignores it, and says that 'Branch cannot be empty'.
The api endpoint is /acumaticadb/entity/Default/17.200.001, and I am PUTting JSON to /SalesOrder, trying to create a new order.
The branch field is present in the json on the details level. I tried 'Branch' and 'BranchID' on both order header and order details levels, and still getting the same error.
I tried to specify the branch during login request. Still same error during order creation.
The exact text of the error: "PX.Data.PXException: Error: 'Branch' cannot be empty." The stack trace is not very informative, it says error was thrown when it tried to persist the order.
Through the web UI, orders with items can be created just fine, by the same user.
This question is almost idential to /49039152, but there was no resolution there.
EDIT: Did not notice code did not come through, here is the request:
PUT : http://localhost/acumaticadb/entity/Default/17.200.001/SalesOrder
{
"Details": [{
"OrderQty": {"value": "10"},
"BranchID": {"value": "HQ"},
"Branch": {"value": "HQ"},
"InventoryID": {"value": "CONBABY1"}
}],
"CustomerOrder": {"value": "TOYONEILLTEST"},
"LocationID": {"value": "MAIN"},
"CustomerID": {"value": "TOYONEILL"},
"BranchID": {"value": "HQ"},
"Branch": {"value": "HQ"}
}
Branch screenshot:
Upvotes: 3
Views: 1757
Reputation: 1
This worked for me: Go to the companies screen and find the access role for the company. Add that role to your API users roles from the users screen.
Upvotes: 0
Reputation: 60
In case anyone else comes across the same error and @micwallace's solution didn't work for you.
If you're specifying the optional branch
parameter in your login call, it might be worth double checking that you've used the Branch ID
and not the Branch Name
as value, which can be found on the Branches screen.
e.g. If we were to look at the 2019R1 Sales Demo screenshot attached, and wanted to use the Products Retail branch from the Revision Two Products company, the correct value to use in the login call would be PRODRETAIL.
{
"name" : "{{api_username}}",
"password" : "{{api_password}}",
"company" : "{{tenant_login_name}}",
"branch" : "PRODRETAIL",
"locale" : "{{locale_code}}"
}
Upvotes: 0
Reputation: 480
I spent hours trying to fix this and finally came to a solution. The problem for me was that the user that I was using for the API did not have the user role required to access the specified branch/company. It was a case of a very misleading error message. I think I'm using the same "Sales Demo" test data as you. I'm a bit late to the party but I hope this helps others.
To fix:
Upvotes: 1