Patch Request
To invoke a Patch you POST
a request in the structured JSON format or using multipart/form-data. To understand how the patch process works, refer to the Patch Guide.
End point
POST /api/json/v1/patch
JSON Request
Request
{
"a": {
"type": "file",
"path": "inputA.json"
},
"b": {
"type": "file",
"path": "inputB.json"
},
"patchDirection": "aToB"
"dxConfig": [
{
"ignoreChanges": "delete",
"key": "created"
}
]
}
The request allows the parameters to be changed from their default values.
JSON A
{
"a": "your data",
"b": "bbc 1",
"name": "John Joe Smith",
"age": 21,
"owner": true,
"hobbies": [
"playing guitar badly",
"reading",
"Cinema"
]
}
JSON B
{
"a": "my data",
"b": "bbc 2",
"name": "Mr John Smith",
"hobbies": [
"Badminton",
"guitar",
"reading"
],
"age": 22,
"pet": "dog"
}
The response below indicates the response of the patch request with JSON A and JSON B inputs. Remember that JSON arrays are indexed from 0.
Response
HTTP/1.1 200 Created
[
{
"op": "replace",
"path": "/a",
"value": "my data"
},
{
"op": "replace",
"path": "/b",
"value": "bbc 2"
},
{
"op": "replace",
"path": "/name",
"value": "Mr John Smith"
},
{
"op": "remove",
"path": "/owner"
},
{
"op": "remove",
"path": "/hobbies/2"
},
{
"op": "add",
"path": "/hobbies/1",
"value": "guitar"
},
{
"op": "replace",
"path": "/hobbies/0",
"value": "Badminton"
},
{
"op": "replace",
"path": "/age",
"value": 22
},
{
"op": "add",
"path": "/pet",
"value": "dog"
}
]
The example above shows how patch inputs could be specified using a File IO. The ajson
and bjson
object in the request can contain different types of members according to the types of data being processed. This is described in more detail in the I/O types page.
Form Input
In addition to requests in structured JSON format, multipart/form-data can also be used.
For example:
Request
POST /api/json/v2/patch HTTP/1.1
Content-Type: multipart/form-data; boundary=boundary-id
Content-Length: number_of_bytes_in_entire_request_body
--boundary-id
Content-Disposition: file; a="inputA.json"
Content-Size: 98344
Content-Type: application/json
... JSON ...
--boundary-id
Content-Disposition: file; b="inputB.json"
Content-Size: 92224
Content-Type: application/json
... JSON ...
--boundary-id
Content-Disposition: form-data; name="patchDirection"
aToB
--boundary-id
Content-Disposition: form-data; name="dxConfig"
{
"dxConfig": [
{
"ignoreChanges": "delete",
"key": "created"
}
]
}
--boundary-id
Patch Model
When specifying a patch, these are the various available objects:
Object | Description | ||
---|---|---|---|
a (required) | Input A JSON file See this page for the various I/O types available. | ||
b (required) | Input B JSON file See this page for the various I/O types available. |
For more details about parameters, refer Patch Parameters.
Parameter | Type | Default | Description |
---|---|---|---|
patchDirection | string | aToB | This parameter decides the direction in which patch is applied Available options:
|
dxConfig | string | A parameter with a value containing an array of configuration instructions. For example,
TEXT
|