API Cuverie

Patch handling

 

Patch definition

Patch is used to change an existing resource, applying some changes on it. It differs from PUT method, as the PUT replaces the entire resource with the given definition. The PATCH method only applies specified changes.
A patch consists of a list of operations to apply to the existing object. Each operation is applied in the given order.

The JSON patch definition is used as stated by the RFC 6902.

General format

A patch definition is an array of operations. An operation has 3 items: the , the path used to locate the part of the resource to modify, and the value:

Operations

Operation name

Description

add Add a property or an item to an array. If the property already exists, it will set the value
remove Removes a property or an item from an array
replace Equivalent to a remove operation followed by an add operation with the same path
move Equivalent to a remove operation followed by an add operation with the same path, and using value from source
copy Equivalent to an add operation, using value from source
test Returns a success status code if the value at the path is equals to the specified value (a validation error occus otherwise)