Patching
Cloud CMS supports the use of HTTP Patch (RFC 5789) along with JSON Patch (RFC 6902) to describe atomic updates to content objects. This allows for lighter JSON payloads by only requiring property-level differences to be sent over the wire instead of full document payloads. JSON Patch supports many property operations including add, remove, move and copy as well as insertion within arrays and key/field manipulation for objects.
The HTTP Patch method is invoked like this:
PATCH /repositories/{repositoryId}/branches/{branchId}/nodes/{nodeId}/patch
The content type should be set to application/json
. The payload of the HTTP PATCH call should be a JSON array containing the JSON Patch payload.
Patching only applies to existing content objects and can only be used to modify existing objects. It cannot be used to create new content items or delete content items. It also only works against a single content object at a time.
If you're interested in making bulk changes, please take a look at Cloud CMS Transfer.
An Example
Suppose that you have an existing content object that looks like this:
{
"title": "Hello World",
"category": "my_category"
}
Now suppose that you'd like to add a property called discount
with a value of 0.2
. To do so, you can fire an HTTP PATCH method call with a JSON body like this:
[{
"op": "add",
"path": "discount",
"value": 0.2
}]
The resulting node will look like this:
{
"title": "Hello World",
"category": "my_category",
"discount": 0.2
}
Reference
For more information about HTTP Patch (RFC 5789):
For more information about JSON Patch (RFC 6902):
Here is a web site with some good reference material: