Making OCI REST API calls with OCI cli and the oci raw-request command option


OCI cli has a general option called raw-request that can be utilised to make a call to whatever existing OCI service using its endpoint. This is the syntax:

oci raw-request --http-method [GET|POST|...] --target-uri https://<service-endpoint>.oraclecloud.com/<api-method-path>

Example 1: Getting the namespace name of the object storage associated to a tenancy

oci raw-request --http-method GET --target-uri https://objectstorage.eu-frankfurt-1.oraclecloud.com/n/
{
"data": "inxxxvd",
"headers": {
"Content-Length": "13",
...
},
"status": "200 OK"
}

Example 2: Listing objects in a bucket

oci raw-request --http-method GET --target-uri https://objectstorage.eu-frankfurt-1.oraclecloud.com/n/inxxxvd/b/test/o
 {
   "data": {
     "objects": [
       {
         "name": "OtrosFicherosProperties.zip"
       },
       {
         "name": "Scripts.zip"
       },
       {
         "name": "shs.zip"
       }
     ]
   },
   "headers": {
     "Content-Length": "94",
     ...
   },
   "status": "200 OK"
 }

Hope it helps! 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.