Change a Person

Once your client application has retrieved a person, it can modify it and submit the changed version. If you are following this example using curl from the command line, you can simply copy the returned entry into a text editor and manually change one of the values. For example:

<vdf:field name="com.escenic.city">Oslo</vdf:field>

and save the results to a file (called my-edited-person.xml, for example).

To commit your change you have to submit a PUT request to the same URI that you would use to retrieve it (that is, the URI supplied in the search results entry edit or self link).

curl --include -u user:password -X PUT -H "If-Match: *" -H "Content-Type: application/atom+xml" \
> http://host-ip-address/webservice/escenic/person/20 --upload-file my-edited-person.xml
HTTP/1.1 100 Continue

HTTP/1.1 204 No Content
Server: Apache-Coyote/1.1
Date: Tue, 20 Mar 2012 05:50:26 GMT

In order for the PUT operation to work, you must specify two HTTP headers as shown above:

Content-Type: application/atom+xml

You must specify the content type of the data you are uploading.

If-Match: *

The If-Match header value * is used here for reasons of simplicity. It is acceptable to use it for test and demonstration purposes, but should never be used in a production system. For more information about this header and what it does, see Optimistic Concurrency.

If you're using curl, it's a good idea to specify --include with PUT operations: curl will then output the response header returned from the web service as shown above, and you can verify whether or not the operation was successful:

  • A response code in the 2xx range indicates success.

  • A response code in the 4xx range means that you made an invalid edit and the server won’t accept your modification.

  • A response code in the 5xx range means there is a server error.

Submitting a change in this way may not work if the resource you are attempting to modify is already locked by another client application. For more information about this and about how locking works, see Lock a Content Item.