Change the Business Date or Current Branch

When you use the contract-based REST API, the current date is used as the business date, and the branch that you specified when signing in is used as the current branch. When you create or update a record by using the contract-based REST API, you may need to use other values of the business date or current branch. To do this, you use the custom HTTP headers PX-CbApiBusinessDate and PX-CbApiBranch in the HTTP requests you make. See the following sections for details on the request and the response.

Note: The new values that you specify for the business date or current branch are valid only for the current HTTP request.

HTTP Method and URL

When you create or update a record in MYOB Acumatica, you use the PUT HTTP method and the following URL.

PUT http://<Base endpoint URL>/<Top-level entity>
The URL has the following components:
  • <Base endpoint URL> is the URL of the contract-based endpoint through which you are going to work with MYOB Acumatica, which has the following format: http://<MYOB Acumatica instance URL>/entity/<Endpoint name>/<Endpoint version>/.
  • <Top-level entity> is the name of the entity for which you are going to create or update a record.

For example, suppose that you want to update a stock item record in a local MYOB Acumatica instance with the name AcumaticaDB by using a system endpoint with the name Default and Version 23.200.001. You would use the following HTTP method and URL to update a record.

PUT http://localhost/AcumaticaDB/entity/Default/23.200.001/StockItem

Parameters

For information on the request parameters, see the Parameters section of Create a Record and the Parameters section of Update a Record.

Request Headers

You can use the following optional headers for changing the business date or current branch.
Header Description
PX-CbApiBusinessDate Optional. Specifies the new business date. The date can be specified in any format. If you omit this header, the current date is used as the business date.
PX-CbApiBranch Optional. Specifies the new current branch. The branch should be specified as a branch name. If you omit this header, the branch that you specified when signing in is used as the current branch.

Request Body

For information on the request body, see the Request Body section of Create a Record and the Request Body section of Update a Record.

Response Status Codes

For information on possible response status codes, see the Response Status Codes section of Create a Record and the Response Status Codes section of Update a Record.

Example

The following request is an example of creating a new journal transaction with SweetLife Store set as the new current branch and 01-Jan-2023 set as the business date.

Tip: In the request example below, <MYOB Acumatica instance URL> is the URL of the MYOB Acumatica instance (such as https://my.acumatica.com/MyInstance). You can omit the instance name in the URL (that is, you can use https://my.acumatica.com) if the instance is installed in the root of the website.
PUT / HTTP/1.1
Host: [<MYOB Acumatica instance URL>]/entity/Default/23.200.001/JournalTransaction
Accept: application/json
Content-Type: application/json
PX-CbApiBusinessDate: 2023/01/01
PX-CbApiBranch: SweetLife Store

{
    "Description": {"value": "Test transaction description"},
    "PostPeriod": {"value": "01-2023"}
}