In this blog, I will cover vRealize Automation 8.x operations using REST API via Postman. The main goal of this blog is to provide a handy example for vRA operation using API.
The vRealize Automation REST API provides consumer, administrator, and provider-level access to the service catalog with the same services that support the vRealize Automation console user interface.
You can perform vRealize Automation functions programmatically by using REST API service calls.
The vRealize Automation REST API offers multiple services and functions. For a detailed offering, please refer to VMware Programming Guide for vRA.
REST Client Applications
Any client application that can send HTTPS requests is an appropriate tool for developing REST applications with the vRealize Automation API. The following open-source applications are commonly used:
- cURL
- Postman application
Let us go through some of the vRA operations using the Postman client. I presume you have already installed or had access to Postman client or plugin, whichever suites best for your environment.
We will start with creating some Environment Variables for the vRA interface. The Environment variables will be used in sending your requests to API endpoints that you want to reach and perform some actions
Variables allow you to store and reuse values in your requests and scripts. By storing a value in a variable, you can reference it throughout your collections, environments, and requests—and if you need to update the value, you only have to change it in one place. Using variables increases your ability to work efficiently and minimizes the likelihood of error.
Define Postman environments
Here, I have added vRA information as part of the necessary variables.
- va-fqdn: Hostname/IP for the virtual appliance (or load balancer)
Authentication
Most of the vRealize Automation API calls are authorized by relevant roles. Before executing any API, make sure you login with relevant user authorized to perform the operation. Each of these use cases should have a login method. Send a login call after setting postman environment and it will retrieve the token and will set in environment variable in Postman. There is no need to copy the token over to next API method authorization header as all the APIs headers are set. Use above mentioned environment variable and modify according to your setup.
Let us login into the vRA and get the refresh token. We will use the necessary variables for the vRA hostname and user credentials to authenticate.
Send another API POST call to get the Bearer token.
Next, let us list down the Blueprints or Cloud templates from vRA using GET API Call.
Here we will use Bearer Token as a Variable. It is the same Bearer token we retrieved in the earlier step.
The above Blueprint was published as a Catalog item by the Cloud Admins. Thus, we will look for the exact Blueprint in the Service Broker Catalog using the GET catalog item API call.
Finally, let us deploy the NGINX application based on the Catalog item we retrieved from the Service Broker from the earlier step.
We can verify the deployment from the vRA service Broker UI as well.
I hope you enjoyed this post. I’d be very grateful if you’d help share it on Social Media. Thank you!