< Previous | Contents | Next >

4.4.2 Retrieving Versions

HCP responds to PUT requests with the X-HCP-VersionId header when creating objects in a namespace with versioning enabled.

X-HCP-VersionId: 79885459513089

X-HCP-VersionId is used to explicitly retrieve historic versions of objects. Let’s modify the program listing in Section

2.2.1 to retrieve a version of the object examples/world.txt with version identifier 79885459513089.

//specify namespace URL - eg. ns01.tn01.hcp01.hitachi.com/rest/path

String url = "http://ns01.tn01.hcp01.hitachi.com/rest/examples/world.txt?" + "version=79885459513098";

The GET method is used to retrieve historical versions of objects. The ID of the version to retrieve is specified in-line as a URL parameter. The code required to download a specific version of an object otherwise remains the same as the code required to download the current version. As always, object data is returned in the response body on success.