2 Examine the response, which always includes an HTTP response code and usually includes a body. In
the Data Director API, a response body is an XML or JSON representation of an object, including
elements and attributes that represent object properties, links that implement operations on the object
or provide references to contained or containing objects and, if the object is being created or modified,
an embedded task object that tracks the progress of the creation or modification. The response also
includes an HTTP response code, which indicates whether the request succeeded or failed, and might
be accompanied by a URL that points to a location from which you can retrieve additional information.
These operations can repeat, in this order, for as long as necessary.
Create a Data Director REST Request
To retrieve object data, you can make HTTP requests to the Data Director API. In response to a POST, GET,
PUT, or DELETE request, the server returns the requested data as XML or JSON values depending on the
format you specify in the HTTP header.
Most REST APIs follow the same sequence of steps to implement a call. If you are already an experienced
REST API user, you can skip this section.
Procedure
1 Create a string that has the following format for the HTTP request.
Option Description
HTTP verb
POST, GET, PUT, or DELETE.
url
The URL consists of the host name and the path. The host name is the
network name of the computer that is running Data Director. The path is
the path to the Data Director API package on your computer or network.
headers
The Data Director API supports standard HTTP Accept headers as follows:
Content-type
The value of the Content-type header is
application/xml or application/json, depending on
which request format you use. Always use a
Content-type header with PUT or POST requests
that include a request body.
Accepts
The value of the Accepts header is application/xml
or application/json, depending on the return format
you require. Always use the Accepts header with
GET requests that expect a response body in return.
Authorization:
HTTP basic authentication (RFC 2617).
Location
Requests that create an object, including all
asynchronous requests, which create a task object,
return the created object's URL via this header.
what to do
Either an action or a request body. For simple boolean requests, use an
action. Otherwise, use a request body. See the VMware vFabric Data Director
Call Reference . For examples of object representations, see
http://.../datadirector/api/dataformat.
When you use HTTP GET with any of the Enumerate calls (collection
URLs), the call returns a list of URLs that contain the names of the objects
in a collection. Use HTTP GET again with each of the URLs to retrieve the
data for a specific object. All collection URLs support encoding as
application/xml, application/json, or text/plain media types.
2 Specify authentication information.
REST APIs accept HTTP basic authentication on each request, encoded with an existing Data Director
username and password credential.
3 Encode the XML or JSON request body, if needed.
VMware vFabric Data Director Programming Guide
12 VMware, Inc.