Atom feed of this document
 
 
 

 3.4. Request/Response Types

The Cloud Databases API supports both the JSON and XML data serialization formats. The request format is specified using the Content-Type header and is required for calls that have a request body. The response format can be specified in requests either by using the Accept header or by adding an .xml or .json extension to the request URI. Note that it is possible for a response to be serialized using a format different from the request. If no response format is specified, JSON is the default. If conflicting formats are specified using both an Accept header and a query extension, the query extension takes precedence.

Table 3.2. Response Formats
Format Accept Header Query Extension Default
JSON application/json .json Yes
XML application/xml .xml No

In the request example below, notice that Content-Type is set to application/json, but application/xml is requested via the Accept header:

 

Example 3.6. Request with Headers: JSON

POST /v1.0/1234/instances HTTP/1.1
Host: ord.databases.api.rackspacecloud.com
Content-Type: application/json
Accept: application/xml
X-Auth-Token: eaaafd18-0fed-4b3a-81b4-663c99ec1cbb

{
    "instance": {
        "name": "'my_instance_name'",
        "flavorRef": "https://ord.databases.api.rackspacecloud.com/v1.0/1234/flavors/1",
        "volume": {
            "size": "2"
        }
    }
}

Therefore an XML response format is returned:

 

Example 3.7. Response with Headers: XML

HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: 380
Date: Thu, 17 Nov 2011 02:37:37 GMT

<instance created="2011-11-03T15:57:52Z"
    hostname="d735f61b985bb003a61dc72948dbf4e7174da12c.rackspaceclouddb.com"
    id="00ff11ee-22dd-33cc-44bb-55aa66007799" name="orion" status="BUILD" updated="2011-11-03T15:57:55Z"
    xmlns="http://docs.openstack.org/database/api/v1.0">
    <links>
        <link href="https://ord.databases.api.rackspacecloud.com/v1.0/1234/instances/00ff11ee-22dd-33cc-44bb-55aa66007799" rel="self"/>
        <link href="https://ord.databases.api.rackspacecloud.com/instances/00ff11ee-22dd-33cc-44bb-55aa66007799" rel="bookmark"
        />
    </links>
    <volume size="2"/>
    <flavor id="2">
        <links>
            <link href="https://ord.databases.api.rackspacecloud.com/v1.0/1234/flavors/2"
                rel="self"/>
            <link href="https://ord.databases.api.rackspacecloud.com/flavors/2"
                rel="bookmark"/>
        </links>
    </flavor>
</instance>