How to connect to vCloud director using REST API clients ?



We all have had the use case to connect to vCloud director via API to pull some details. Below is the detailed process on how to connect using REST client.

I am using the Postman windows client. The procedure will remain the same for the other REST client applications too.

Step 1 :

Download the postman client
https://www.getpostman.com/downloads/

Step 2 (Optional) : 

You may have to disable the SSL certificate verification if you are trying this on a test environment and do not have trusted certificates


Step 3:


  • Enter the credentials under the Authorization tab
You must append either @system to the username or @orgname. This depends on the role you have. As a system administrator, you must use @system because your admin user is not bound to a special organization. As org admin or org user, you must append your organization name.

For example: administrator@system or orgadmin@wecloud



  • Enter the Accept header under the Headers tabs
Key : Accept 
Value : application/*+xml;version=32.0

The version can any supported value. The list of supported version can be exported using the below process. 

GET  https://vcd_url/api/versions



In my case, I am using version 32.0 which the latest supported for vCD 9.7




Step 4:

Create a Session by clicking on Send and this will generate an authorization token



  • The Status 200 OK means the query responded with no issues.
  • x-vcloud-authorization is the session authentication token for retrieving or updating future queries

Step 5 : 

  • Update the x-vcloud-authorization and its value under Headers section 


Example API query : 

How to list all organizations?


  1. Create a session using the above mentioned steps 
  2. Use the generated authorization token under Headers tab
  3. Run the below API query


GET https://vcd.wecloud.lab/api/org





This is it! The above procedure will allow you to connect to your VCD instance using API. You can refer to the VCD API reference guide to browse through all the API queries.

vCloud director API reference documents for different versions can be found in the below link  :

https://docs.vmware.com/en/vCloud-Director/index.html






Hope it helps 😀

Comments

Popular posts from this blog

vCloud director 9.7 appliance deployment step by step guide

How to Install and Uninstall Guest agent for vRA Windows machines

Unable to change Provider VDC virtual hardware support beyond version 10