The OpenStack Identity API supports both the
JSON and XML data serialization formats. The request
format is specified using the Content-Type
header and is required for operations that have a request
body. The response format can be specified in requests
using either the Accept
header or 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
(see example below). 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.
Format | Accept Header | Query Extension | Default |
JSON | application/json | .json | Yes |
XML | application/xml | .xml | No |
Example 1.1. JSON Request with Headers
POST /v2.0/tokens HTTP/1.1 Host: identity.api.openstack.org Content-Type: application/json Accept: application/xml
{ "auth":{ "passwordCredentials":{ "username":"test_user", "password":"mypass" }, "tenantName":"customer-x" } }
Example 1.2. XML Response with Headers
HTTP/1.1 200 OKAY Date: Mon, 12 Nov 2010 15:55:01 GMT Content-Length: Content-Type: application/xml; charset=UTF-8
<?xml version="1.0" encoding="UTF-8"?> <access xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://docs.openstack.org/identity/api/v2.0"> <token id="ab48a9efdfedb23ty3494" expires="2010-11-01T03:32:15-05:00"> <tenant id="t1000" name="My Project" /> </token> <user id="u123" name="jqsmith"> <roles> <role id="100" name="compute:admin"/> <role id="101" name="object-store:admin" tenantId="t1000"/> </roles> </user> <serviceCatalog> <service type="compute" name="Cloud Servers"> <endpoint tenantId="t1000" region="North" publicURL="https://compute.north.host.com/v1/t1000" internalURL="https://compute.north.host.internal/v1/t1000"> <version id="1" info="https://compute.north.host.com/v1/" list="https://compute.north.host.com/" /> </endpoint> <endpoint tenantId="t1000" region="North" publicURL="https://compute.north.host.com/v1.1/t1000" internalURL="https://compute.north.host.internal/v1.1/t1000"> <version id="1.1" info="https://compute.north.host.com/v1.1/" list="https://compute.north.host.com/" /> </endpoint> </service> <service type="object-store" name="Cloud Files"> <endpoint tenantId="t1000" region="North" publicURL="https://storage.north.host.com/v1/t1000" internalURL="https://storage.north.host.internal/v1/t1000"> <version id="1" info="https://storage.north.host.com/v1/" list="https://storage.north.host.com/" /> </endpoint> <endpoint tenantId="t1000" region="South" publicURL="https://storage.south.host.com/v1/t1000" internalURL="https://storage.south.host.internal/v1/t1000"> <version id="1" info="https://storage.south.host.com/v1/" list="https://storage.south.host.com/" /> </endpoint> </service> <service type="dnsextension:dns" name="DNS-as-a-Service"> <endpoint tenantId="t1000" publicURL="https://dns.host.com/v2.0/t1000"> <version id="2.0" info="https://dns.host.com/v2.0/" list="https://dns.host.com/" /> </endpoint> </service> </serviceCatalog> </access>