vRA – Quick Tip – Telnet & vRA API calls (Postman)

Helloooo & welcome to our blog!

Today I would like to give you 2 quick tips for troubleshooting & testing / developing in your vRA environment:

  1. Telnet on the vRA Appliances
  2. Postman for executing vRA API calls

Telnet on vRA Appliances

We all know how to check whether a remote machine is listening on specific ports for requests, or if a certain port can be reached on the network passing through firewalls and more network magic: telnet.

Well how can we use telnet on the vRA appliances? With one simple command:

curl -v telnet://<target ip address>:<desired port number>

All you have to do is open an SSH connection to one of your appliances and execute the above command. Here’s an example:

curl -v telnet://externalvRO.some.domain:8281

A successful connection is shown as:

* Rebuilt URL to: telnet://externalvRO.some.domain:8281/
*   Trying 192.168.1.35...
* TCP_NODELAY set
* Connected to externalvRO.some.domain (192.168.1.35) port 8281 (#0)

If the machine you’re trying to reach is denying connections on that port, you might see something similar to this:

* Rebuilt URL to: telnet://externalvRO.some.domain:8289/
*   Trying 192.168.1.35...
* TCP_NODELAY set
* connect to 192.168.1.35 port 8289 failed: Connection refused
* Failed to connect to externalvRO.some.domain port 8289: Connection refused
* Closing connection 0
curl: (7) Failed to connect to externalvRO.some.domain port 8289: Connection refused

If a firewall is blocking your request, you might see something similar to this:

* Rebuilt URL to: telnet://8.8.8.8:443/
*   Trying 8.8.8.8...
* TCP_NODELAY set
*

Happy connection troubleshooting vRA chiefs!

Postman – vRA API Calls

The vRA API works in the following way:

  1. First you need to authenticate against the vRA API to retieve a Bearer Token
  2. With that Bearer Token you can execute other API calls against vRA’s API.

A very useful tool to execute REST API calls & do some API development is Postman. Postman is available in different downloads:

  • Windows Application
  • MacOS Application
  • Google Chrome Plugin

Some Postman links below:

The vRA API Documentation can be found here

Well, how do we authenticate with the vRA API? With a simple API call:

URL = https://<Your-vRA-Appliance>/identity/api/tokens
Method = POST
Headers = Content-Type : application/json
Body = 
{
"username": "<your_vra_account>@vsphere.local",
"password": "<your_vra_account's_password>",
"tenant": "<tenantName>"
}

This will give us an Authorization Bearer Token to use in our future API calls!

How does that look in Postman? Well like this:

Schermafbeelding 2019-06-29 om 14.34.48

Schermafbeelding 2019-06-29 om 14.36.00

And the response looks like this, the Bearer Token can be found in the ‘id‘ field of the response’s body:

Schermafbeelding 2019-06-29 om 14.38.26

And now you can use this Bearer Token to execute other API calls! All you have to do is include this Bearer Token in the header of your API call.

Let’s say you want to get all the Reservations in vRA via an API call, that can be achieved by doing this:

URL = https://<Your-vRA-Appliance>/reservation-service/api/reservations
Method = GET
Header values = 
Accept : application/json
Content-Type : application/json
Authorization : Bearer <your_bearer_token_here>

This is how that looks in Postman:

Schermafbeelding 2019-06-29 om 14.48.07

And the response looks like this:

Schermafbeelding 2019-06-29 om 14.49.51

Hopefully you’re now all settled to play around with vRA’s API!

Happy developing!

 

 

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 )

Google photo

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

Twitter picture

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

Facebook photo

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

Connecting to %s

%d bloggers like this:
search previous next tag category expand menu location phone mail time cart zoom edit close