Skip to main content
Skip table of contents

Graft Request

To invoke a Graft you POST a request in the structured JSON format or using multipart/form-data. To understand how the graft process works, refer to the Guide to JSON Graft.

End point
CODE
POST /api/json/v1/graft

JSON Request

Request
JS
{
  "changeset": {
    "type": "file",
    "path": "graft-changeset.json"
  },
  "target": {
    "type": "file",
    "path": "graft-changeset.json"
  },
  "graftResolutionMode": "changesetPriority"
}

The request allows the parameters to be changed from their default values.

Graft Changeset
TEXT
{
  "dx_deltaJSON": {
    "dx_data_sets": "A!=B",
    "dx_deltaJSON_type": "diff",
    "dx_deltaJSON_metadata": {
      "operation": {
        "type": "compare",
        "input-format": "json_uris",
        "output-format": "JSON"
      },
      "parameters": {
        "output": "fullContext",
        "arrayAlignment": "typeWithValuePriority",
        "wordByWord": false
      }
    },
    "dx_deltaJSON_delta": {
      "a": {
        "dx_delta": {
          "A": "your data",
          "B": "my data"
        }
      },
      "b": {
        "dx_delta": {
          "A": "bbc 1",
          "B": "bbc 2"
        }
      },
      "name": {
        "dx_delta": {
          "A": "John Joe Smith",
          "B": "Mr John Smith"
        }
      },
      "age": {
        "dx_delta": {
          "A": 21,
          "B": 22
        }
      },
      "hobbies": [
        {
          "dx_delta": {
            "A": "playing guitar badly",
            "B": "Badminton"
          }
        },
        {
          "dx_delta": {
            "B": "guitar"
          }
        },
        "reading",
        {
          "dx_delta": {
            "A": "Cinema"
          }
        }
      ],
      "owner": {
        "dx_delta": {
          "A": true
        }
      },
      "pet": {
        "dx_delta": {
          "B": "dog"
        }
      }
    }
  }
}
Graft Target
TEXT
{
  "a": "your data",
  "b": "ITV",
  "name": "Dr John Smith",
  "age": 22,
  "owner": false,
  "hobbies": [
    "playing guitar badly",
    "reading",
    "Cinema",
    "Baseball"
  ],

The response below indicates the graft result for the above request. 

Response
TEXT
HTTP/1.1 200 Created
{
  "a": "my data",
  "b": "bbc 2",
  "name": "Mr John Smith",
  "age": 22,
  "hobbies": [
    "Badminton",
    "guitar",
    "reading",
    "Baseball"
  ],
  "pet": "dog",
  "added": "element"
}

The example above shows how comparison inputs could be specified using a FileIO. The changeset and target in the request can contain different types of object 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
TEXT
POST /api/json/v2/graft 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; changeset="changeset.json"
Content-Size: 98344
Content-Type: application/json

... JSON  ...
--boundary-id
Content-Disposition: file; target="target.json"
Content-Size: 92224
Content-Type: application/json

... JSON  ...
--boundary-id

Content-Disposition: form-data; name="graftResolutionMode"
changesetPriority
--boundary-id

Graft Model

When specifying a graft, these are the various available objects:

Object

Description

changeset

(required)

The JSON delta file (produced by our compare operation) represents a set of changes.

See this page for the various I/O types available. 

target

(required)

Target JSON File.

See this page for the various I/O types available. 

For more details about parameters, refer Graft Parameters.

Parameter

Type

Default

Description

graftResolutionMode

string

changesetPriority

The result of a Graft is a resolved result. This parameter controls how this resolution is handled.

Available options:

  • changesetPriority - when there are conflicts, choose the version present in the changeset

  • additionsOnly - when there are conflicts, choose the target version, and also resolve elements added in the changeset


JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.