Send Requests

Use the following guidelines when sending requests using the Compute Classic REST API.

URL Structure

To perform operations on a Compute Classic resource by using REST API calls, you must specify the fully-qualified, unique URI of the resource.

The fully qualified URI of a resource is in the following format:

https://{api_endpoint}/{resource_base_path}/{resource_name}
Where:
  • api_endpoint is the REST endpoint URL of the site in which you want to manage Compute Classic resources. Some examples in this guide use https://api-z999.compute.us0.oraclecloud.com as the REST endpoint URL. To find out the REST endpoint URL for a site:

    1. Sign in to your Cloud Account and navigate to the My Services Dashboard.

      • For Oracle Cloud, see Signing in to Your Cloud Account in Getting Started with Oracle Cloud.

      • For Oracle Cloud at Customer, click the My Services URL from the welcome email.

      The Oracle Cloud My Services Dashboard page is displayed. It lists the services that are assigned to your account.

    2. Click action menu near the upper left corner of the page.

      The CLOUD SERVICES menu is displayed.

    3. Select Compute.

      The Compute Classic console is displayed.

    4. Click Site near the top of the page and select the site that you want to find out the REST endpoint URL for.

    5. In the Site Selector dialog box that is displayed, note the URL in the REST Endpoint field.

  • resource_base_path is the base URI of the resource. For example, for SSH public keys, the base URI is /sshkey. To view the REST resources, arranged alphabetically by resource path, see All REST Endpoints.

  • resource_name is the multi-part name of the specific resource. Most resources have a three-part name, which consists of the two-part user name that you pass during authentication followed by an object name:

    {two-part-user-name}/{object_id}
    • If you are using a traditional cloud account, use the following format for the resource_name:

      /Compute-{identityDomainName}/{user}/{object_id}
      
    • If you are using a cloud account with Identity Cloud Service (IDCS), use the following format for the resource_name:

      /Compute-{serviceInstanceID}/{user}/{object_id}
      

    For more information about identifying the two-part user name, see Authentication

Note:

All examples in this document use /Compute-acme/jack.jones@example.com as the two-part user name. If you are using a Cloud Account with IDCS, replace acme in the two-part user name with your service instance ID.

Example

For example, the following is the fully-qualified URI of the sshkey object named key1 created by the jack.jones@example.com user of the acme identity domain:

https://api-z999.compute.us0.oraclecloud.com/sshkey/Compute-acme/jack.jones@example.com/key1
  • Requests to add an object must be made to the base path of that resource. For example, specify the following URI to add an SSH key:

    https://api-z999.compute.us0.oraclecloud.com/sshkey/
    
  • Requests to update or delete an object must be made to the complete resource name of the object. For example, specify the following URI to delete or update the /Compute-acme/jack.jones@example.com/key1 SSH key:

    https://api-z999.compute.us0.oraclecloud.com/sshkey/Compute-acme/jack.jones@example.com/key1

Supported Methods

You can perform basic CRUD operations (create, read, update, and delete) on Compute Classic objects using standard HTTP method requests, as summarized in the following table.

HTTP Method Description
GET

Retrieves information about the objects specified in the request URI.

POST

Creates an object by using the JSON-formatted data in the request body.

PUT

Updates the attributes of an object by using the JSON-formatted data in the request body.

Use this request to update one or many attributes of an object.

DELETE

Deletes the object specified in the request URI.

Each object for which you can perform API calls is identified uniquely by its URI. Note that some of these methods may not be supported for certain objects. To see the methods that you can invoke for each object, see All REST Endpoints.

Media Types

The following media types are supported by the Compute Classic REST API:

  • application/json

Supported Headers

The Compute Classic REST API supports the following headers that may be passed in the header section of the HTTP request or response.

Header Description Example
Accept:

With a few exceptions, the Compute Classic API returns JSON-encoded data in its responses. So the Accept: header must be set to indicate this. The API protocol version (v3) must also be specified.

  • For GET calls to retrieve just the names (not details) of objects in a container, set this header to application/oracle-compute-v3+directory+json

  • For all other purposes, set the header to application/oracle-compute-v3+json

Accept: application/oracle-compute-v3+json
Accept-Encoding:

List of acceptable encoding to support compression. The API supports sending and receiving UTF-8 encoded data only. Ensure that your HTTP client is appropriately set to encode and decode character data, including JSON data.

Accept-Encoding: gzip;q=1.0, identity; q=0.5
Content-Encoding List of acceptable encoding to support compression. Content-Encoding: deflate
Content-Type:

All the content in an HTTP request body sent to the API server must be encoded in JavaScript Object Notation (JSON). The API protocol version is also specified in the Content-Type: header in both request and response messages. The currently used content types are as follows:

  • application/oracle-compute-v3+json

  • multipart/oracle-compute-v3+form-data.

The server specifies the expected version of the data in the response in the Content-Type: header.

If the server does not support the version specified by the client in the request, it responds with HTTP status code 415 (Unsupported Media Type). If the server can't provide a response in any of the versions supported by the client, it responds with status code 406 (Not Acceptable).

Content-Type: application/oracle-compute-v3+json
Cookie:

The Cookie: header must be included with every request to the service. It must be set to the value of the set-cookie header in the response received to the POST /authenticate/ call. See Authentication.

Cookie: $COMPUTE_COOKIE

COMPUTE_COOKIE is the name of the variable in which you store the authentication cookie. See Quick Start.

Compression

Use compression on the Compute Classic REST resource request and response for improved performance. To use compression, include one of the following HTTP headers in the request: Accept-Encoding or Content-Encoding.