OCI REST APIs from Postman
For creating/updating/deleting a user/compute/database/API Keys or anything for that matter we usually have four ways:
1. OCI Console.
2. OCI REST APIs through Postman.
3. OCI REST APIs through CURL commands.
4. OCI REST APIs through OCI SDKs.
In this blog, we will focus our discussion around using OCI REST APIs from Postman only.
1. You should have access to OCI console.
2. You need to have details of Tenancy OCID, User OCID, API Fingerprint, Public & Private Keys used while generating API Fingerprint & OCI Region where you want to fire REST API.
You can fetch Tenancy & User OCID from OCI Console. Another way is to create an API Key (i.e., Fingerprint) and it’s config file will give you details of Tenancy & User OCID, along with Fingerprint and Region.
To generate API Key, Login to OCI console, click on Profile on Top right corner of the Home page → Click on User Settings (if using old version of OCI Console), for the latest version click on My Profile under the Profile on Top right corner of the Home page.
Click on API Keys under Resources → Click Add API Key and go ahead with the default option by downloading the Public/Private Keys and click Add API Key.
This creates the API Key, now go to the configuration file of the Key
This file gives you the Tenancy/User OCID, along with region and Fingerprint
This completes the pre-requisites:
a. Tenancy OCID
b. User OCID
d. Private key (which you have downloaded while generating API Key).
A basic Postman project for Oracle REST APIs is available, where Environment variables are defined, Collections are created & Pre-Request script is created which you can download from the GitHub link.
Import the below files to your Postman:
Update Environments in Postman
Post importing the above mentioned files, you should update the environments file in Postman by providing details you have collected above and save the changes.
Initialize REST API Collection
Once you are done updating Environments file with respective details, run the ONE_TIME_INITIALIZATION_CALL request which is part of OCI_REST_INITIALIZATION collection.
This is just to initialize the collection which fetches required data from Environments.
Trigger OCI REST APIs
The default OCI_REST_COLLECTION which we have imported will have two APIs:
1. Get Announcements 2. Create_OCI_Streams.
Update the endpoint for these API calls with respective details like your OCI Region, compartment OCID, etc., based on the REST API you chose to trigger.
Oracle has provided documentation for all the REST APIs along with required/optional fields which can be found here.
This blog, explains in details on how to use CURL for making OCI REST API calls.