Request and response types

The Rackspace Cloud DNS 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 adding an .xml or .json extension to the request URI. A response can be serialized using a format that is different from the request. If no response format is specified, JSON is the default. If conflicting formats are specified by using both an Accept header and a query extension, the query extension takes precedence.

JSON and XML response formats

FormatAccept headerQuery extensionDefault
JSONapplication/json.jsonYes
XMLapplication/xml.xmlNo

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

Example: Request with headers: XML

POST https://dns.api.rackspacecloud.com/v1.0/1234/domains
Accept: application/xml
X-Auth-Token: ea85e6ac-baff-4a6c-bf43-848020ea3812
Content-Type: application/json
Content-Length: 71

{
  "name" : "example.com",
  "emailAddress" : "[email protected]"
}

Therefore an XML response format is returned:

Example: Response with headers: XML

<jobId>e63886c9-acf0-4e5d-8023-09a0fae37446</jobId>
<callbackUrl>https://dns.api.rackspacecloud.com/v1.0/1234/status/e63886c9-acf0-4e5d-8023-09a0fae37446</callbackUrl>
<status>RUNNING</status>
<requestUrl>http://dns.api.rackspacecloud.com/v1.0/1234/domains/</requestUrl>
<verb>POST</verb>

The following example shows an alternative method of achieving the same result. This time, we utilize a URI extension (.xml) to request an XML response format instead of an Accept header:

Example: Extension: XML request

POST https://dns.api.rackspacecloud.com/v1.0/1234/domains.xml
X-Auth-Token: ea85e6ac-baff-4a6c-bf43-848020ea3812
Content-Type: application/json
Content-Length: 71

{
  "name" : "example.com",
  "emailAddress" : "[email protected]"
}