3

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:

Hq Branch

John Smith
  • 31
  • 3
  • It might be worth looking at the User Profile of who you're logging in as to ensure a default branch is set. – Kyle S May 23 '18 at 15:48
  • The default branch in the user profile is set, has always been set. – John Smith May 23 '18 at 15:53
  • It might be worth looking at your login method and your get/put method as part of your question. – Kyle S May 23 '18 at 15:54
  • 1
    There is little flexibility in the login method -- you specify username, password, company, and optional branch. Specifying branch did not help. GETting an existing order -- with the details expanded -- shows a branch field on every detail. PUTting a new order -- with the branch field on the same level, detail level -- results in the error described. – John Smith May 23 '18 at 16:09
  • Added the body of the request to the question (didn't notice it didn't come through the first time). – John Smith May 23 '18 at 16:20
  • And the final step, can you send me a screenshot (or something) of the branch you're trying to use? Usually when a "Error: 'X' cannot be empty." it might not exist in the system. – Kyle S May 23 '18 at 16:52
  • 1
    Added the screenshot. It is the test data that came with Acumatica ERP installer. – John Smith May 23 '18 at 17:07
  • Just so things don't seem like they are lingering I took the snippet you posted with the criteria of 1. User having default branch, 2. created new branch, 3. and some psuedo information for the sales order. I was able able to create the Sales Order. Ran in both 6.1 and 2017. Haven't had a chance to test in 2018. Sorry I can't be anymore help. Good luck! – Kyle S May 23 '18 at 20:17
  • I'm not too familiar with web service API but shouldn't BranchID be an integer type? I would think you get Branch is empty because it was set to null when it failed validation. – Hugues Beauséjour May 23 '18 at 22:08

3 Answers3

1

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:

  1. Go to the companies screen and find the access role for the company.
  2. Add that role to your API users roles from the users screen.
micwallace
  • 480
  • 5
  • 13
0

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

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.

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 06 '23 at 08:12