Retrieve Records by Conditions

To retrieve records that satisfy the specified conditions from MYOB Advanced by using the contract-based REST API, you access the needed URL address with the GET HTTP method and specify filtering conditions in the parameters of the method. See the following sections for details on the request and the response.

HTTP Method and URL

If you need to retrieve the list of records that satisfies the specified conditions, you use the GET HTTP method and the following URL.

GET 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 Advanced. This URL has the following format: http://<MYOB Advanced instance URL>/entity/<Endpoint name>/<Endpoint version>/.
  • <Top-level entity> is the name of the entity for which you are going to retrieve the list of records.

For example, suppose that you want to retrieve the list of stock item records from a local MYOB Advanced instance with the name AcumaticaDB by using the system endpoint with the name Default and Version 22.200.001. You should use the following URL to retrieve the list of records.

http://localhost/AcumaticaDB/entity/Default/22.200.001/StockItem

Parameters

You can use the following parameters when you retrieve records from MYOB Advanced:
  • $filter: To specify filtering conditions that identify the record to be updated
  • $skip: To specify the number of records to be skipped from the list of returned records
  • $top: To specify the number of records to be returned in the list
  • $expand: To specify the linked and detail entities to be expanded
    Note: In Contract Version 4, you are required to list in the $expand parameter every detail and related entity that you are going to have in the response body. For Contract Version 2 and 3, the detail and related entities contained in the request body are also contained in the response body, regardless of whether they are listed in the $expand parameter or not.
  • $select: To specify the fields of the entity to be returned
  • $custom: To specify the fields that are not defined in the contract to be returned

For detailed descriptions of the parameters, see Parameters for Retrieving Records.

Request Headers

You can specify the following header in the request.

HeaderDescription
Accept

Specifies the format of the response body, which should be application/json.

Response Status Codes

The following table lists the HTTP status codes that the system returns for a request that retrieves records by conditions.

CodeDescription
200The request has been completed successfully. The response body contains the list of records that satisfy the specified conditions.
401

The user is not signed in to the system.

403

The user has insufficient rights to access the MYOB Advanced form that corresponds to the entity.

429

The number of requests has exceeded the limit imposed by the license (see License Restrictions for API Users).

500

An internal server error has occurred.

Example

The following request shows an example of the retrieval of StockItem records that are Active and that have been modified since the specified date.
Tip: In the request example below, <MYOB Advanced instance URL> is the URL of the MYOB Advanced 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.
GET ?$expand=WarehouseDetails&$filter=ItemStatus%20eq%20'Active'%20and%20LastModified%20gt%20
    datetimeoffset'2019-08-18T23%3A59%3A59.999%2B04%3A00' HTTP/1.1
Host: [<MYOB Advanced instance URL>]/entity/Default/22.200.001/StockItem
Accept: application/json
Content-Type: application/json

Usage Notes

When multiple records are retrieved from MYOB Advanced through an endpoint with Contract Version 3 or 4, the system tries to optimize the retrieval of the records and obtain all needed records in one request to the database (instead of requesting the records one by one). If the optimization fails, the system returns an error, which specifies the entities or fields that caused the failure of the optimized request. To prevent the error from occurring, you can do any of the following:
  • If you do not need to retrieve the entities or fields that caused the failure, you can exclude these entities or fields from the request as follows:
    • Exclude the entities from the entities specified in the $expand parameter.
    • Explicitly specify the other fields to be returned (while excluding the fields that caused the failure) by using the $select parameter.
  • If you need to retrieve the entities or fields that caused the failure, you can retrieve the needed records one by one either by key fields, or by IDs. For more information, see Retrieve a Record by Key Fields and Retrieve a Record by ID.