Use cURL

The examples within this document use cURL to demonstrate how to access the Oracle Transaction Manager for Microservices (MicroTx) REST API.

Task 1: Install cURL

The examples within this document use the cURL command-line tool to demonstrate how to access the MicroTx REST API.

To connect securely to the server, you must install a version of cURL that supports SSL and provide an SSL certificate authority (CA) certificate file or bundle to authenticate against the Verisign CA certificate. For more information about authentication, see Authenticate.

The following procedure demonstrates how to install cURL on a Windows 64-bit system.

  1. In your browser, navigate to the cURL home page at http://curl.haxx.se and click Download in the left 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 install the software.

  3. Navigate to the cURL CA Certs page at http://curl.haxx.se/docs/caextract.html and download the ca-bundle.crt SSL CA certificate bundle in the folder where you installed cURL.

  4. 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 an SSL certificate authority (CA) certificate bundle. For example:

    C:\curl> set CURL_CA_BUNDLE=ca-bundle.crt

You are now ready to send requests 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=ca-bundle.crt

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
--cacert Specifies the location of the CA certificate bundle on the local machine.

Note:

It is not mandatory to provide this option while running cURL commands. However, if the Peer certificate cannot be authenticated with known CA certificates error occurs, use this option to provide the location of the appropriate certificate file or bundle.
-H --header Defines one or both of the following:
  • authentication cookie in the request header
  • Content type of the request document
-i Displays response header information.
-X Indicates the type of request (for example, GET, PUT).

For example:

curl -X GET 
        --cacert ~/cacert.pem
        -H <request-header>:<value> 
        https://<api-endpoint>/<path>/<resource-path>

The following example cURL command retrieves details of all XA transactions.

curl -X GET
     -H "Authorization:Bearer $OTMM_COOKIE" 
      https://192.0.2.1:8080/admin/v1/xa-transaction

OTMM_COOKIE is the name of the variable in which you stored the authentication token earlier. For information about retrieving the authentication token and storing it in a variable, see Authenticate.