GET'>
PUT'>
POST'>
DELETE'>
'>
'>
]>
cURL commandscURL is a command-line tool that you can use to interact
with REST interfaces. cURL lets you to transmit and receive
HTTP requests and responses from the command line or a shell
script, which enables you to work with the API directly. It is
available for Linux distributions, Mac OS X, and Windows. For
information about cURL, see http://curl.haxx.se/.To run the cURL request examples shown in this guide, copy
each example from the HTML version of this guide directly to
the command line or a script.Before you can run these examples, you must set environment
variables. See .This example cURL command shows account details and lists
containers in the account.#curl -i $publicURL?format=json \
-X GET -H "X-Auth-Token: $token"HTTP/1.1 200 OK
Content-Length: 96
X-Account-Object-Count: 1
X-Timestamp: 1389453423.35964
X-Account-Meta-Subject: Literature
X-Account-Bytes-Used: 14
X-Account-Container-Count: 2
Content-Type: application/json; charset=utf-8
Accept-Ranges: bytes
X-Trans-Id: tx274a77a8975c4a66aeb24-0052d95365
Date: Fri, 17 Jan 2014 15:59:33 GMTThe response, in JSON format, is:[
{
"count": 0,
"bytes": 0,
"name": "janeausten"
},
{
"count": 1,
"bytes": 14,
"name": "marktwain"
}
]The carriage returns in the cURL request examples are
escaped with a backslash (\) character.
The escape character allows continuation of the command
across multiple lines. However, do not include the escape
character in the JSON or XML request body within the cURL
command.The cURL examples in this guide use the following
command-line options:
cURL command-line options
Option
Description
Sends the specified data in a &POST; request
to the HTTP server. Use this option to send a
JSON or XML request body to the server.
Specifies an extra HTTP header in the
request. You can specify any number of extra
headers. Precede each header with the
option.
Includes the HTTP response headers in the
output.
Silent or quiet mode. Does not show progress
or error messages. Makes cURL mute.
Transfers the specified local file to the
remote URL.
Specifies the request method to use when
communicating with the HTTP server. The
specified request is used instead of the
default method, which is &GET;.
json.toolFor commands that return a response, you can append the
following code to the command to call the json.tool to
pretty-print output:| python -m json.toolTo use the json.tool, import the
json module. For information about
the json.tool, see json — JSON encoder and decoder.If you run a Python version older than 2.6, import the
simplejson module and use the
simplejson.tool. For information
about the simple.json tool, see simplejson — JSON encoder and decoder.If you do not want to pretty-print JSON output, omit
this code.Example of an XML responseTo request an XML response, append the
format=xml query parameter to the
request.This example cURL command shows account information and
list containers in the account, and asks for the response
in XML:#curl -i $publicURL?format=xml \
-X GET -H "X-Auth-Token: $token"HTTP/1.1 200 OK
Content-Length: 262
X-Account-Object-Count: 1
X-Timestamp: 1389453423.35964
X-Account-Meta-Subject: Literature
X-Account-Bytes-Used: 14
X-Account-Container-Count: 2
Content-Type: application/xml; charset=utf-8
Accept-Ranges: bytes
X-Trans-Id: tx69f60bc9f7634a01988e6-0052d9544b
Date: Fri, 17 Jan 2014 16:03:23 GMT<?xml version="1.0" encoding="UTF-8"?>
<account name="my_account">
<container>
<name>janeausten</name>
<count>0</count>
<bytes>0</bytes>
</container>
<container>
<name>marktwain</name>
<count>1</count>
<bytes>14</bytes>
</container>
</account>