Retrieve Records with Attributes

In MYOB Acumatica, some records have attributes that are visible on the Attributes tab of the data entry form. For details about attributes, see Attributes.

You may have to retrieve the records along with their attributes by using the contract-based REST API. To do this, you access the needed URL with the GET HTTP method, and in the parameters of the request, you specify the desired record fields and the fields that correspond to the needed attributes and attribute values. See the following sections for details on the request and the response.

HTTP Method and URL

When you retrieve records from MYOB Acumatica, you use the GET HTTP method and the following URL.

http://<Base endpoint URL>/<Top-level entity>

In this URL:

  • <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 retrieve the list of records along with their attributes.

For example, suppose that you want to retrieve the list of contacts along with their attributes from a local MYOB Acumatica instance with the name AcumaticaDB, and you want to use the system endpoint with the name Default and Version 23.200.001. You would use the following URL.

http://localhost/AcumaticaDB/entity/Default/23.200.001/Contact

Parameters

When you retrieve records along with their attributes, you should use the following parameters:
  • $select: To list the desired record fields and the fields that correspond to the needed attributes and attribute values
  • $expand: To expand the detail entity that contains the fields that correspond to the attributes and attribute values
For example, for the Contact entity, to retrieve the values of attributes of records, you need to specify Attributes/AttributeID and Attributes/Value (or Attributes/ValueDescription) in the $select parameter, and Attributes in the $expand parameter. To learn the exact names of the fields that correspond to the attributes for a particular entity, you should review the fields of this entity on the Web Service Endpoints (SM207060) form or refer to the OpenAPI specification of the endpoint.

You can also use other parameters that are mentioned in Retrieve Records by Conditions. 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 along with their attributes.

Code Description
200 The request has been completed successfully. The response body contains the data retrieved from the MYOB Acumatica instance in JSON format.
400

The data specified in the request is invalid.

401

The user is not signed in to the system.

403

The user has insufficient rights to access the MYOB Acumatica 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 is an example of the retrieval of the FirstName, LastName, and JobTitle fields of contacts (that is, the Contact top-level entity), and the AttributeID and Value fields of the contacts’ attributes.
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.
GET ?$expand=Attributes&$select=FirstName,LastName,JobTitle,Attributes/AttributeID,Attributes/Value HTTP/1.1
Host: [<MYOB Acumatica instance URL>]/entity/Default/23.200.001/Contact
Accept: application/json
Following is an example of a response.
[
    ...
    {
        "id": "6a47c888-0b10-e911-9fbe-7c5cf8918e20",
        "rowNumber": 20,
        "note": {
            "value": ""
        },
        "Attributes": [
            {
                "id": "dfe79fb3-b6a0-43a9-afa2-6641b943424d",
                "rowNumber": 1,
                "note": null,
                "AttributeID": {
                    "value": "INTEREST"
                },
                "Value": {},
                "custom": {}
            }
        ],
        "FirstName": {
            "value": "Stephane"
        },
        "JobTitle": {
            "value": "Customer Service & Network Manager"
        },
        "LastName": {
            "value": "Sans"
        },
        "custom": {}
    },
    ...
]

Usage Notes

In the Default/20.200.001 and Default/23.200.001 endpoints, the attributes of top-level entities are exposed in the AttributeValue entities. An AttributeValue entity has the following fields:
  • AttributeID : The attribute identifier. Both internal values and external values can be used to set this field, but only the internal value can be retrieved.
  • AttributeDescription: The external value of the attribute identifier. The field is read-only.
  • Value: The attribute value. When the value is retrieved, the internal value is returned. To set the value, the internal value and the external value (for control types other than multiselect combo boxes) can be used. For multiselect combo boxes, an external value can be accepted only if it contains a single value without commas. For various control types, the following rules apply to the Value field:
    • For check boxes, 0 is returned if the check box is not selected, and 1 is returned if the check box is selected. For setting a value, 0, 1, false (case-insensitive), or true (case-insensitive) can be used.
    • For multiselect combo boxes, values separated by commas (namely, Value1,Value2,Value3) compose the internal value.
    • For selectors, the values are set and retrieved in the same way as they are for text boxes.
    • For date edit boxes, the internal values must be parsable through the use of the System.Globalization.CultureInfo.InvariantCulture Microsoft .NET object.
    • For combo boxes of all types, date edit boxes, and check boxes, an error message is written to the error field when an attempt is made to set an unsupported value.
  • ValueDescription: The external value of the attribute. The field is read-only. The external value is based on the control type as follows:
    • For text boxes and date edit boxes, the external value is the same as the internal value.
    • For check boxes, the external value can be either True or False.
    • For combo boxes, the label is used as the external value.
    • For multiselect combo boxes, labels separated by commas and spaces after commas (namely, Label1, Label2, Label3) compose the external value.
  • Required: An indicator of whether the attribute is mandatory. This field is read-only.
  • RefNoteID: The value of the NoteID field of the object to which this attribute is referred. This field is read-only.