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
For example: administrator@system or orgadmin@wecloud
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
How to list all organizations?
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
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?
- Create a session using the above mentioned steps
- Use the generated authorization token under Headers tab
- 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
Post a Comment