Oracle Cloud ERP provides a comprehensive set of REST APIs for managing financial data, invoices, suppliers, purchase orders, and more. However, Oracle does not provide a native command-line tool for interacting with these APIs. Administrators and DevOps engineers who need to automate REST API calls are left to piece together complex cURL commands, manually encode Base64 authentication headers, and write custom wrapper scripts for every integration.
This approach is fragile and insecure. Passwords end up in shell history files, scripts break when endpoints change, and transient network failures require manual re-execution. For teams managing multiple Oracle Cloud environments, the overhead compounds quickly, turning routine API calls into time-consuming maintenance burdens.
Fusion Toolkit CLI solves this problem with a dedicated oracle-cloud-rest-client command that handles authentication, retries, and response capture automatically. Credentials are stored encrypted on disk and never appear in command arguments or shell history. Every call returns a consistent exit code, making it straightforward to integrate Oracle Cloud REST API automation into shell scripts, cron jobs, CI/CD pipelines, and Kubernetes workflows.
This article walks through practical examples of calling Oracle Cloud REST APIs from the command line using Fusion Toolkit CLI, from fetching data and updating records to downloading binary attachments and building automated workflows.
Why Automate Oracle Cloud REST API Calls
Limitations of Manual API Interaction
Organizations that interact with Oracle Cloud REST APIs manually or through ad-hoc scripts face several persistent challenges:
- No native CLI tool: Oracle Cloud does not ship a command-line utility for REST API calls. Every interaction requires a custom HTTP request.
- Manual Base64 authentication: cURL calls require manually encoding the username and password as a Base64 string for the Authorization header on every invocation.
- No credential management: Without a secure credential store, passwords end up hard-coded in scripts or visible in shell history, creating security risks.
- No retry logic: Transient network timeouts and connection failures require manual detection and re-execution, which is impractical for automated workflows.
- Manual result handling: API responses must be manually redirected to files and parsed, with no consistent structure for downstream processing.
Benefits of Using Fusion Toolkit CLI for REST API Calls
Fusion Toolkit CLI’s oracle-cloud-rest-client command addresses each of these limitations:
- Encrypted credentials: Username, password, and hostname are stored AES-encrypted in a local configuration file. They never appear in command arguments or shell history.
- Automatic authentication: The Basic Auth header is constructed automatically from the encrypted credential store on every request.
- Built-in retry with exponential backoff: Network timeouts and connection errors are retried automatically (3 attempts with exponential backoff), eliminating transient failures without manual intervention.
- Response saved directly to file: JSON responses and binary attachments are written to the specified output file, ready for downstream processing.
- Consistent exit codes: Every command returns exit code 0 on success and 1 on error, enabling reliable integration with shell scripts, cron jobs, and monitoring tools.
- Custom headers support: Specialized endpoints requiring additional HTTP headers are supported through comma-separated key:value pairs.
Practical Guide: Calling Oracle Cloud REST APIs with Fusion Toolkit CLI
The following examples demonstrate the core operations available through the oracle-cloud-rest-client command: fetching data with GET, updating records with PATCH, creating records with POST, and downloading binary attachments.
Configure Fusion Toolkit CLI
Before making any REST API calls, configure Fusion Toolkit CLI with your Oracle Cloud credentials and license key:
java -jar ./fusion-cli-toolkit.jar set-config \
--username="YOUR_ADMIN_USER" \
--password="YOUR_SECURE_PASSWORD" \
--hostname="https://your-pod.fa.ocs.oraclecloud.com:443" \
--licenseKey="YOUR_LICENSE_KEY"
This stores all credentials encrypted on disk. You only need to run this once per environment. (For detailed setup instructions and prerequisites, see the Fusion Toolkit Documentation.)
Example 1: Fetch Invoices (GET)
Retrieve a list of Accounts Payable invoices from Oracle Cloud using a GET request:
java -jar ./fusion-cli-toolkit.jar oracle-cloud-rest-client \
--url="/fscmRestApi/resources/11.13.18.05/invoices?limit=25" \
--operation="getWithHeaders" \
--resultFile="./invoices.json"
On success, the CLI outputs a confirmation with the HTTP status code:
License is valid until 2026-02-08
Sending GET request to URL: https://your-pod.fa.ocs.oraclecloud.com:443/fscmRestApi/resources/11.13.18.05/invoices?limit=25 | Response Code: 200
The full JSON response is saved to ./invoices.json, containing the invoice records returned by the Oracle Cloud REST API. You can use any standard JSON tool (jq, Python, etc.) to parse and process the results.
Example 2: Update an Invoice (PATCH)
To update an existing record, first create a JSON body file containing the fields to modify. For example, create update-invoice.json:
{
"Description": "Updated via Fusion Toolkit CLI"
}
Then execute the PATCH request, specifying the invoice ID in the URL and the body file path:
java -jar ./fusion-cli-toolkit.jar oracle-cloud-rest-client \
--url="/fscmRestApi/resources/11.13.18.05/invoices/12345" \
--operation="patchWithBody" \
--body="./update-invoice.json" \
--resultFile="./patch-result.json"
The CLI sends the PATCH request with the JSON body and saves the API response to ./patch-result.json. Any HTTP 2xx status code is treated as success (exit code 0), while other status codes return exit code 1.
Example 3: Create a Record (POST)
Creating new records follows the same pattern as PATCH. Prepare a JSON body file with the record data. For example, create new-supplier.json:
{
"Supplier": "Acme AG",
"SupplierNumber": "SUP-2026-001",
"TaxpayerCountry": "CH",
"BusinessRelationship": "SPEND_AUTHORIZED"
}
Then submit the POST request:
java -jar ./fusion-cli-toolkit.jar oracle-cloud-rest-client \
--url="/fscmRestApi/resources/11.13.18.05/suppliers" \
--operation="postWithBody" \
--body="./new-supplier.json" \
--resultFile="./post-result.json"
The response, including the newly created record’s identifiers and default field values, is saved to ./post-result.json for verification or further processing.
Example 4: Download an Attachment (Binary)
Oracle Cloud REST APIs expose binary attachments (PDFs, images, spreadsheets) through child resource endpoints. The getWithAttachment operation downloads these files directly to disk:
java -jar ./fusion-cli-toolkit.jar oracle-cloud-rest-client \
--url="/fscmRestApi/resources/11.13.18.05/invoices/12345/child/attachments/67890/FileContents" \
--operation="getWithAttachment" \
--headers="Accept:application/octet-stream" \
--resultFile="./invoice-attachment.pdf"
The binary content is written directly to the specified file path. This is particularly useful for automating document extraction workflows, such as downloading invoice PDFs for archival or QR code processing.
Automate REST API Calls with Cron and Shell Scripts
The real power of CLI-based API interaction comes from combining multiple calls into automated workflows. Because every Fusion Toolkit CLI command returns consistent exit codes, you can chain operations, implement conditional logic, and schedule recurring tasks with standard shell tools.
Shell Script: Chain Multiple REST API Calls
The following script fetches invoices on hold, processes each one, and logs the results:
#!/bin/bash
# fetch-and-process-invoices.sh
# Fetch held invoices and export the result for downstream processing
TOOLKIT_JAR="/opt/fusion-toolkit/fusion-cli-toolkit.jar"
OUTPUT_DIR="/opt/fusion-toolkit/output"
LOG_FILE="/var/log/fusion-toolkit/rest-api.log"
echo "[$(date)] Starting invoice fetch..." >> "$LOG_FILE"
# Step 1: Fetch invoices on hold
java -jar "$TOOLKIT_JAR" oracle-cloud-rest-client \
--url="/fscmRestApi/resources/11.13.18.05/invoices?q=InvoiceStatus='On hold'&limit=100" \
--operation="getWithHeaders" \
--resultFile="$OUTPUT_DIR/held-invoices.json"
if [ $? -eq 0 ]; then
echo "[$(date)] Successfully fetched held invoices." >> "$LOG_FILE"
else
echo "[$(date)] ERROR: Failed to fetch held invoices." >> "$LOG_FILE"
exit 1
fi
# Step 2: Download attachment for a specific invoice
java -jar "$TOOLKIT_JAR" oracle-cloud-rest-client \
--url="/fscmRestApi/resources/11.13.18.05/invoices/12345/child/attachments/67890/FileContents" \
--operation="getWithAttachment" \
--resultFile="$OUTPUT_DIR/invoice-12345.pdf"
if [ $? -eq 0 ]; then
echo "[$(date)] Attachment downloaded successfully." >> "$LOG_FILE"
else
echo "[$(date)] ERROR: Attachment download failed." >> "$LOG_FILE"
exit 1
fi
echo "[$(date)] Invoice processing complete." >> "$LOG_FILE"
Schedule with Cron
Schedule the script to run every 30 minutes during business hours, Monday through Friday:
crontab -e
Add the following entry:
*/30 8-18 * * 1-5 /opt/fusion-toolkit/fetch-and-process-invoices.sh >> /var/log/fusion-toolkit/cron.log 2>&1
Integration with Monitoring Tools
Because the CLI returns exit code 0 for success and exit code 1 for failure, you can integrate it directly with monitoring and alerting platforms. Cron job monitoring tools such as Healthchecks.io, Cronitor, or Kubernetes CronJob failure policies can detect non-zero exit codes and trigger alerts immediately. Your existing infrastructure monitoring already knows how to handle process exit codes, so no additional integration work is required.
Resilience & Pagination
Oracle Cloud REST calls occasionally fail with transient network errors or HTTP 502/503/504 gateway responses, and Oracle’s collection endpoints paginate results with a per-page ceiling of 500 records. Fusion Toolkit CLI v2.2 adds two flags that make long-running REST automation robust against both:
--max-retries N: Automatically retries transient network errors and HTTP 502/503/504 gateway responses using exponential backoff (default 3; set to 0 to disable retries entirely). Permanent 4xx errors are never retried.--paginatewith--page-size: Auto-paginates through every page of an Oracle REST collection and merges the items into a single result file. Combine with--page-size 500(Oracle’s per-page maximum) to minimise the number of round-trips.
The following example fetches every Accounts Payable invoice on hold across all pages, using 500-record pages and up to five retries for transient failures:
java -jar ./fusion-cli-toolkit.jar oracle-cloud-rest-client \
--url="/fscmRestApi/resources/11.13.18.05/invoices?q=InvoiceStatus='On hold'" \
--operation="getWithHeaders" \
--paginate \
--page-size 500 \
--max-retries 5 \
--resultFile="./all-held-invoices.json"
The result file contains the merged collection across every page, ready for downstream processing — no hand-rolled pagination loop, no retry scaffolding, and no silent data loss when Oracle’s gateway briefly returns a 503.
Benefits of CLI-Based Oracle Cloud REST API Automation
Adopting Fusion Toolkit CLI for Oracle Cloud REST API automation delivers measurable advantages across security, operations, and engineering workflows:
- Security: Credentials are AES-encrypted at rest and never exposed in command arguments, scripts, or shell history. No more plaintext passwords in cURL commands.
- Scriptability: Consistent command syntax and exit codes make it straightforward to build complex multi-step workflows with standard shell scripting.
- Monitoring: Exit codes integrate natively with cron, Kubernetes CronJobs, CI/CD pipelines, and any process monitoring tool that checks return codes.
- Reliability: Built-in retry with exponential backoff handles transient network failures automatically, eliminating a common source of false failures in automated workflows.
- Consistency: The same CLI tool and credential store works across all Oracle Cloud REST API endpoints, reducing the maintenance burden of managing multiple custom scripts per endpoint.
- Cross-platform: The CLI runs on any platform with Java 17, including Linux servers, Windows workstations, Docker containers, and Kubernetes pods.
By using Fusion Toolkit CLI for Oracle Cloud REST API automation, teams eliminate manual API interaction, improve credential security, and unlock the full power of Oracle Cloud’s REST interface for scripted and scheduled workflows. Whether you are fetching financial data for reporting, patching records as part of an integration pipeline, or downloading attachments for document processing, the oracle-cloud-rest-client command provides a reliable, secure, and automatable foundation.
For detailed command reference, additional examples, and configuration guides, visit the Fusion Toolkit Documentation.
