Use cURL

The examples throughout the documentation use cURL to demonstrate how to access the Oracle Java Cloud Service REST API.

Task 1: Install cURL

cURL is an open source, command-line tool for transferring data with URL syntax, supporting various protocols including HTTP and HTTPS. To connect securely to the REST server, you must install a version of cURL that supports SSL.

To install cURL on your system:

  1. In your browser, navigate to the cURL home page at http://curl.haxx.se and click Download in the navigation menu.

  2. On the cURL Releases and Downloads page, locate the SSL-enabled version of the cURL software that corresponds to your operating system. Click the link to download the ZIP file, and extract the executable to the desired folder.

When running cURL from a Windows command shell only, you must provide an SSL certificate authority (CA) file or bundle to authenticate against the Verisign CA certificate.

  1. Navigate to the cURL CA Extract page at http://curl.haxx.se/docs/caextract.html and download the cacert.pem SSL CA certificate file in the folder where you installed cURL.

  2. Open a command window, navigate to the directory where you installed cURL, and set the cURL environment variable, CURL_CA_BUNDLE, to the location of the SSL CA certificate file. For example, on a Windows system you would enter:

    C:\curl> set CURL_CA_BUNDLE=cacert.pem

You are now ready to send REST requests to the Oracle Java Cloud Service instance using cURL.

Task 2: Set Environment Variable for cURL

In a command window, set the cURL environment variable, CURL_CA_BUNDLE, to the location of your local CA certificate bundle. For example:

C:\curl> set CURL_CA_BUNDLE=cacert.pem

For information about CA certificate verification using cURL, see http://curl.haxx.se/docs/sslcerts.html.

Task 3: Invoke cURL

Invoke cURL and specify one or more of the command-line options defined in the following table, as required, to direct its execution.

cURL Option Description

-d, --data @file.json

Specifies the request body, or data, either directly or by referring to a JSON file on the local machine.

-F, --form @file.json

Specifies form data, either directly or by referring to a JSON file on the local machine.

-H

Defines a request header.

-i

Displays response header information.

-u, --user

Specifies the user name and password for the Oracle Java Cloud Service account.

-X

Indicates the type of request (for example, GET, POST, and so on).

The following cURL command example retrieves the details of the ExampleInstance service instance in the identity domain ExampleIdentityDomain:

curl -i -X GET -u username:password -H "X-ID-TENANT-NAME:ExampleIdentityDomain" https://rest_server_url/paas/api/v1.1/instancemgmt/ExampleIdentityDomain/services/jaas/instances/ExampleInstance

Note: The command in the example uses the URL structure https://rest_server_url/resource-path, where rest_server_url is the REST server to contact for your identity domain or Cloud Account. See Send Requests.