Web Services: New PATCH Method in the REST API
In previous versions of MYOB Acumatica, to
update a record by using the REST API, a developer had to use the PUT
HTTP
method. In MYOB Acumatica
2025.1, the developer can use the new PATCH
method to update only particular
fields of an existing record.
Behavior of the PUT and PATCH Methods
The PUT
method updates the fields as follows:
- To find the fields to update, the system compares the values specified in the request body with the field values for the record in the system.
- The system skips the values in the request body that are equal to the field values in the system.
- The system updates only the fields for which the value specified in the request body
differs from the value stored in the system.
However, during this update, other fields of the record may be changed because of the logic implemented in the respective graph. Meanwhile, the request body may include values specified for the fields that have been updated because of the graph logic. In this case, the system does not save the values specified in the request body.
The PATCH
method updates exactly the fields specified in the request body,
regardless of the values for these fields that are stored in the system. However, the
PATCH
method does not override the graph logic. For example, if because
of the graph logic, the value cannot be changed as the request body specifies, this value
will not be changed.
Use of the PATCH Method
A developer may consider using the PATCH
method during the synchronization
of records from an external system when the developer knows exactly which fields have been
changed in the external system. The developer may also use this method in situations when
particular fields of a record cannot be updated with a PUT
request (as
described in the previous section).
In a request with the PATCH
method, the developer needs to identify the
record and specify only the fields that should be updated. The developer can identify the
record by key fields, by ID, or by filtering conditions. For details about the
PATCH
method, see Update Particular Fields of a Record.
Example
Suppose that the developer needs to update the order quantity and discount amount in a detail line of the 000029 sales order. The developer can use the following request.
PATCH /entity/Default/24.200.001/SalesOrder?
$expand=Details&
$select=Details/DiscountAmount,Details/OrderQty,OrderNbr,OrderType HTTP/1.1
Host: [<MYOB Acumatica instance URL>]
Accept: application/json
Content-Type: application/json
{
"OrderType": {"value": "SO"},
"OrderNbr": { "value": "000029" },
"Details": [
{
"id": "a1d07920-a402-e911-b818-00155d408001",
"OrderQty": { "value": 2 },
"DiscountAmount": { "value": 5 }
}
]
}