mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Mark Craig
07.30.2015 5fa2ec90725b29f97d3bfad2c556f2c3b080565b
CR-6577 OPENDJ-1862 Doc patching multiple JSON fields

This patch demonstrates how to change
more than one JSON field in a REST resource.
1 files modified
55 ■■■■■ changed files
opendj-server-legacy/src/main/docbkx/admin-guide/chap-rest-operations.xml 55 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/docbkx/admin-guide/chap-rest-operations.xml
@@ -888,6 +888,61 @@
}</computeroutput>
  </screen>
  <para>
   You can change the value of more than one attribute in a patch operation.
   To do so, include multiple operations in the body of the JSON patch.
   Notice that for a multi-valued attribute, the "value" field takes an array,
   whereas the "value" field takes a single value for a single-valued field.
   Also notice in the following example that for single-valued fields,
   an "add" operation has the same effect as a "replace" operation.
  </para>
  <screen>
$ <userinput>curl \
 --user kvaughan:bribery \
 --request PATCH \
 --header "Content-Type: application/json" \
 --data '[
  {
    "operation": "replace",
    "field": "/contactInformation/telephoneNumber",
    "value": "+1 408 555 9999"
  },
  {
    "operation": "add",
    "field": "/contactInformation/emailAddress",
    "value": "barbara.jensen@example.com"
  }
 ]' \
 http://opendj.example.com:8080/users/bjensen</userinput>
<computeroutput>{
    "contactInformation": {
        "emailAddress": "barbara.jensen@example.com",
        "telephoneNumber": "+1 408 555 9999"
    },
    "displayName": "Barbara Jensen",
    "manager": [
        {
            "displayName": "Torrey Rigden",
            "_id": "trigden"
        }
    ],
    "meta": {
        "lastModified": "2015-04-07T10:19:41Z"
    },
    "schemas": [
        "urn:scim:schemas:core:1.0"
    ],
    "_rev": "00000000e68ef438",
    "name": {
        "givenName": "Barbara",
        "familyName": "Jensen"
    },
    "_id": "bjensen",
    "userName": "barbara.jensen@example.com"
}</computeroutput>
  </screen>
  <para>You can use resource revision numbers in <literal>If-Match:
  <replaceable>revision</replaceable></literal> headers to patch the resource
  only if the resource matches a particular version.</para>