• Buy Now
    • Rackspace Cloud
    • Email & Apps
    • Fanatical Support for AWS
    • Managed Google Cloud Platform
    • Office 365
  • Log In
    • MyRackspace Portal
    • Cloud Control Panel
    • Rackspace Webmail Login
    • Cloud Office Control Panel
  • Rackspace Logo
  • Developer Home
  • Developer Documentation
  • Blogs ▼
    • Technical Blog
    • Rackspace Blog
    • Solve: Thought Leadership
  • Support Documentation

Developer Docs


Let’s Build Something Powerful Together!

End-to-End Multicloud Solutions.   Solving Together.™   Learn more at Rackspace.com

Submit an issue
  • Cloud DNS 1.0
  • Getting started
    • Get your credentials
    • Sending API requests to Cloud DNS
      • Convert cURL examples to run on Windows
    • Authenticate to the Rackspace Cloud
      • Authenticate by using cURL
      • Send an authentication request
      • Review the authentication response
      • Configure environment variables
    • Concepts
      • DNS
      • Domain
      • Subdomain
      • Record
      • Domain Owner
    • Create and manage DNS domains
      • Creating a new cloud server
      • Creating a domain
      • Listing domain details
      • Adding records
  • General API Information
    • Service access endpoints
    • DNS Service versions
      • Contract version
      • API version headers
    • Request and response types
    • Supported Record Types
      • Notes
      • Notes
    • Synchronous and asynchronous responses
      • Viewing status of all asynchronous job requests
    • IP Address Support
    • DNS propagation
    • Persistent Connections
    • Content Compression
    • Paginated collections
      • Pagination elements and attributes
    • Limits
      • Rate limits
      • Absolute limits
      • Retrieve account limits
    • Faults
    • Date and time format
    • Comments
    • Role-based access control (RBAC)
      • Assigning Roles to Account Users
      • Roles available for Rackspace Cloud DNS
      • Multiproduct global roles and permissions
      • Resolving conflicts between RBAC multiproduct and product-specific roles
      • RBAC permissions cross-reference to Rackspace Cloud DNS API operations
  • API reference
    • Limits operations
      • List limits
      • Show limits
      • List limit types
    • Domains operations
      • List domains
      • List domains by name
      • Create domain
      • Update domains
      • Delete domains
      • Delete domains and subdomains
      • Search domains
      • List domain details without subdomains
      • Show domain
      • Update domain
      • Delete domain
      • Delete domain and its subdomains
      • Show domain changes
      • Export domain
      • Clone domain
      • Import domain
    • Subdomains operations
      • List subdomains
    • Records operations
      • List records
      • Search records
      • Add records
      • Delete records
      • Update records
      • Delete record
      • Update record
      • Show record details
    • Reverse DNS operations
      • Update PTR records
      • Add PTR records
      • List PTR records
      • Delete PTR records
      • Show PTR record
  • Release notes
    • v1.0.34 Configuration Changes, October 24, 2014
      • What's new
      • Resolved issues
      • Known issues
    • v1.0.34, October 14, 2014
      • What's new
      • Resolved issues
      • Known issues
    • v1.0.33, July 29, 2014
      • What's new
      • Resolved issues
      • Known issues
    • v1.0.31 configuration changes, July 16, 2014
      • What's new
      • Resolved issues
      • Known issues
    • v1.0.31, June 26, 2014
      • What's new
      • Resolved issues
      • Known issues
  • Service updates
  • Additional resources
  • Disclaimer

Sending API requests to Cloud DNS#

This section shows how to send requests by using cURL.

Note

You can also use Rackspace Cloud API services by using the following methods:

  • If you are developing applications or automation, try using Rackspace SDKs, the Rackspace CLI, or OpenStack client applications.
  • For API development, testing and workflow management in a graphical environment, try interacting with the API by using an application such as Postman or RESTClient for Firefox.

cURL is a command-line tool that you can use to interact with REST interfaces. cURL lets you transmit and receive HTTP requests and responses from the command line or a shell script, which enables you to work with the API directly. cURL is available for Linux distributions, Mac OS® X, and Microsoft Windows®. For information about cURL, see http://curl.haxx.se/.

To run the cURL request examples shown in this guide on Mac OS® X or another Linux-based operating system, copy each example directly to the command line or a script.

Note

If you are using Microsoft Windows, you need to adjust the cURL examples to run them. See Convert cURL examples to run on Windows .

Important

The cURL examples in this guide are provided for reference only. Because the use of cURL has environmental dependencies, copying and pasting the examples might not work in your environment.

The following example shows a cURL command for sending an authentication request to the Identity service.

Example: cURL command for sending a JSON request

$ curl https://identity.api.rackspacecloud.com/v2.0/tokens  \
 -X POST \
 -d '{"auth":{"RAX-KSKEY:apiKeyCredentials":{"username":"yourUserName","apiKey":"$apiKey"}}}' \
 -H "Content-type: application/json" \
 | python -m json.tool

In this example, $apiKey is an environment variable that stores your API key value. Environment variables make it easier to reference account information in API requests, to reuse the same cURL commands with different credentials, and to keep sensitive information like your API key from being exposed when you send requests to Rackspace Cloud API services. For details about creating environment variables, see Configure environment variables.

Note

The cURL request examples use a backslash (\) as a line-continuation symbol, which allows the command to continue across multiple lines.

The cURL examples in this guide use the following command-line options.

Option Description
-d Sends the specified data in a POST request to the HTTP server. Use this option to send a JSON request body to the server.
-H

Specifies an extra HTTP header in the request. You can specify any number of extra headers. Precede each header with the -H option.

Common headers in Rackspace API requests are as follows:

  • Content-Type: Required for operations with a request body.

    Specifies the format of the request body. Following is the syntax for the header where format is json:

    Content-Type: application/json
    
  • X-Auth-Token: Required. Specifies the authentication token.

  • X-Auth-Project-Id: Optional. Specifies the project ID, which can be your account number or another value.

  • Accept: Optional. Specifies the format of the response body.

    Following is the syntax for the header where the format is json, which is the default:

    Accept: application/json
    
-i Includes the HTTP header in the output.
-s

Specifies silent or quiet mode, which makes cURL mute. No progress or error messages are shown.

If your cURL command is not generating any output, try replacing the -s option with -i.

-T Transfers the specified local file to the remote URL.
-X Specifies the request method to use when communicating with the HTTP server. The specified method is used instead of the default method, which is GET.

For commands that return a response, you can use json.tool to pretty-print the output. Append the following command to the cURL call:

| python -m json.tool

To use json.tool, import the JSON module. For information about json.tool, see JSON encoder and decoder.

If you run a Python version earlier than 2.6, import the simplejson module and use simplejson.tool. For information about simplejson.tool, see simplejson encoder and decoder.

If you do not want to pretty-print JSON output, omit this code.

Note

If your request includes the -i option to show header output, do not try to pretty-print the output. Header information is not in JSON format, and the API service returns an error if you specify json.tool.

Convert cURL examples to run on Windows#

The cURL examples in the Rackspace API documentation use syntax supported on Mac OS® X, Linux, and UNIX systems. Microsoft Windows does not support the same format. However, you can run the examples on Windows after making the following changes:

  • Replace all the line-continuation backslash characters (\) with a caret (^), and remove any trailing spaces after the ^.
  • If an example includes JSON data, export the data to a text file. When you run the cURL command, use the @filename syntax to import the JSON data. Save the JSON data files in a directory, and run cURL commands from that directory.

The following example shows the cURL format for Linux and UNIX systems:

$ curl https://identity.api.rackspacecloud.com/v2.0/tokens  \
      -X POST \
      -d '{"auth":{"RAX-KSKEY:apiKeyCredentials":{"username":"yourUserName","apiKey":"$apiKey"}}}' \
      -H "Content-type: application/json"

The following example shows the same request with the changes made for Windows systems:

$ curl https://identity.api.rackspacecloud.com/v2.0/tokens  ^
       -X POST ^
       -d @credentials.txt  ^
       -H "Content-type: application/json"
Previous Get your credentials
Next Authenticate to the Rackspace Cloud
Developer Network
  • Developer Center
  • API Documentation and User Guides
  • SDKs
  • Rackspace How-To
Blogs
  • Technical Blog
  • Rackspace Blog
  • Solve: Thought Leadership
Other Information
  • Customer Stories
  • Events
  • Programs
  • Careers
  • Style Guide for Technical Content
©2020 Rackspace US, Inc.
  • ©2020 Rackspace US, Inc.
  • About Rackspace
  • Privacy Statement
  • Website Terms
  • Trademarks