Update
Examples in this documentation depend on features activated in the The code samples demonstrate how to contact the server over HTTPS using the deployment CA certificate. Before trying the samples, generate the CA certificate in PEM format from the server deployment ID and password:
|
Update a resource
Use HTTP PUT to replace any and all writable fields in a resource.
The effect is the same as a patch replace operation.
The following example updates Sam Carter’s telephone number regardless of the revision:
$ curl \
--request PUT \
--cacert ca-cert.pem \
--user dc=com/dc=example/ou=People/uid=kvaughan:bribery \
--header 'Content-Type: application/json' \
--data '{"telephoneNumber": "+1 408 555 1212"}' \
'https://localhost:8443/hdap/dc=com/dc=example/ou=People/uid=scarter?_fields=telephoneNumber&_prettyPrint=true'
{
"_id" : "dc=com/dc=example/ou=People/uid=scarter",
"telephoneNumber" : [ "+1 408 555 1212" ]
}
Update a specific revision
To update a resource only if the resource matches a particular version,
use an If-Match: <revision>
header:
$ export REVISION=$(cut -d \" -f 8 <(curl \
--get \
--cacert ca-cert.pem \
--user dc=com/dc=example/ou=People/uid=kvaughan:bribery \
--header 'Content-Type: application/json' \
--data '_fields=_rev' \
--silent \
'https://localhost:8443/hdap/dc=com/dc=example/ou=People/uid=scarter'))
$ curl \
--request PUT \
--cacert ca-cert.pem \
--user dc=com/dc=example/ou=People/uid=kvaughan:bribery \
--header 'Content-Type: application/json' \
--data '{"telephoneNumber": "+1 408 555 1213"}' \
--header "If-Match: $REVISION" \
'https://localhost:8443/hdap/dc=com/dc=example/ou=People/uid=scarter?_fields=telephoneNumber&_prettyPrint=true'
{
"_id" : "dc=com/dc=example/ou=People/uid=scarter",
"telephoneNumber" : [ "+1 408 555 1213" ]
}
Rename a resource
Refer to the rename action.