How to use Browser based REST Client for Oracle Public Cloud REST API

In my last article I discussed about deploying applications on top of OPC using Bitnami and promised that we will base this article for further development of OPC based environments programatically. One of the main component of such development is knowing your REST API from your cloud provider. Oracle believes in API First Strategy & has a robust REST API for almost all of its cloud services.

So let’s look at how do you get your REST Endpoint from your OPC environment and then we will use it further to initiate authentication from browser based REST Client.

  • Login to your OPC Environment with your credential.
  • Once you login to your OPC Portal, you will see the main dashboard. Note your account name which is your Identity Domain in OPC Cloud. You need it for further steps in the article.
  • Click on the icon shown in the image by the side of your Compute Cloud Services and click on View Details.

OPC Dashboard

Once you go to the Compute Cloud details page, you will find your REST Endpoint as shown in the image below. Make a note of it. You need it for the further steps described in this article.

REST URI

You have all of the information now to test the REST API using your favourite browser based client. For this example we will use Mozilla Firefox Advanced REST Client. To get started with the OPC REST API, you need to first authenticate against your cloud subscription and then get the Authentication Cookie for sending further calls. Let me show you, how you can generate the token and use it for further operations.

  • Open up your Firefox REST Client and select the method as POST.
  • In the URL section type in your <REST Endpoint>/authenticate/
  • OPC supports a different Content Type and that is application/oracle-compute-v3+json. Set the Content-Type header into the client with this mentioned value.
  • For the authentication credential, we have to send it in the Body itself than sending it through Basic Auth Header. The format of the body is as follows:
  • {“user”:”/Compute-<IdentityDomain>/Username“,”password”:”Password“}
  • Change the bold parameters with your own value and click on Send. You will get the Auth Cookie as shown in the following image.

Cookie

  • Now for further operations, you need to use this Cookie into the header and then send further API calls for various different operations.
  • Click on Header -> Custom Header. Set the parameter as Set-Cookie and put the entire line starts from nimbula= as the value of this parameter.

So you are now all set for any type of operations onto the OPC. We will just try to list all of the Instances created so far in the OPC as the further operation to conclude that we set the cookie perfectly and now can do anything thereafter.

  • Change the method as GET.
  • Type the URI as https://<REST Endpoint>/instance/Compute-<Identity Domain>/Username/
  • Click on Send. You will see 200 OK response. Click on the Response Body (Raw) and check the output.
  • Remember it’s Raw value output. You need to use any JSON formatter to format it using RFC 4627 Standard.

This concludes the purpose of this article. I will show you guys, how to use cURL to do some operations in the next article. I will use the DevBox that I have deployed during our Bitnami Application deployment article.

 

About Prasenjit Sarkar

Prasenjit Sarkar is a Product Manager at Oracle for their Public Cloud with primary focus on Cloud Strategy, Oracle Openstack, PaaS, Cloud Native Applications and API Platform. His primary focus is driving Oracle’s Cloud Computing business with commercial and public sector customers; helping to shape and deliver on a strategy to build broad use of Oracle’s Infrastructure as a Service (IaaS) and Platform as a Service (PaaS) offerings such as Compute, Storage, Java as a Service, and Database as a Service. He is also responsible for developing public/private cloud integration strategies, customer’s Cloud Computing architecture vision, future state architectures, and implementable architecture roadmaps in the context of the public, private, and hybrid cloud computing solutions Oracle can offer.