Loading

×Sorry to interrupt
Uncaught ReferenceError: addCTracking is not defined
throws at https://kb.vmware.com/resource/KM_TealiumTrackingJS?v=0.5:100:1

Refresh

Cookie Preference Center

General Information on cookies

When you visit our website, we use cookies to ensure that we give you the best experience. This information does not usually directly identify you, but it can give you a more personalized web experience. Because we respect your right to privacy, you can choose not to allow some types of cookies by clicking on the different category headings to find out more and change your settings. However, blocking some types of cookies may impact your experience on the site and the services we are able to offer. Further information can be found in our

Cookie Policy.

Strictly Necessary

Strictly Necessary

Always Active

Strictly Necessary

Strictly necessary cookies are always enabled since they are essential for our website to function. They enable core functionality such as security, network management, and website accessibility. You can set your browser to block or alert you about these cookies, but this may affect how the website functions. For more information please visit www.aboutcookies.org or www.allaboutcookies.org.

Cookie Details‎

Performance

Performance

Performance

Performance cookies are used to analyze the user experience to improve our website by collecting and reporting information on how you use it. They allow us to know which pages are the most and least popular, see how visitors move around the site, optimize our website and make it easier to navigate.

Cookie Details‎

Please confirm your settings by refreshing the page.

Functional

Functional

Functional

Functional cookies help us keep track of your past browsing choices so we can improve usability and customize your experience. These cookies enable the website to remember your preferred settings, language preferences, location and other customizable elements such as font or text size. If you do not allow these cookies, then some or all of these services may not function properly.

Cookie Details‎

Advertising

Advertising

Advertising

Advertising cookies are used to send you relevant advertising and promotional information. They may be set through our site by third parties to build a profile of your interests and show you relevant advertisements on other sites. These cookies do not directly store personal information, but their function is based on uniquely identifying your browser and internet device.

Cookie Details‎

Advertising Cookies

Consent Leg.Interest

Select All Vendors

Select All Vendors

Select All Hosts

Select All

Clear Filters

Information storage and access

Apply

Confirm My Choices Reject All Allow All

My Subscriptions

Loading

Knowledge Base

How to establish an API connection VMware Cloud Director (56948)

Last Updated: 2/9/2023Categories: How toTotal Views: 36558Language:
Chinese (Simplified)JapaneseEnglish

27 like this article

Subscribe to get an email
newsletter with new updates

27 people found this helpful Please provide article feedback:

Purpose

How to establish a connection to VMware Cloud Director.

Resolution

There are many methods by which a User can connect to the Cloud Director API.
Each method is in essence a REST Client some of which have layers to hide some of the fundamental/basic mechanics surrounding connection.

cURL

Postman

API Explorer (embedded in the Cloud Director UI)

Regardless of the Client, the requirements for each will be the same

VCD_FQDN

Valid Credentials

Valid REST Headers

Valid API Version

Login Session

Token for Subsequent API Calls

VCD_FQDN

This is the FQDN by which your Cloud Director instance is accessible.

https://example.vmware.com/provider

example.vmware.com is the FQDN.

Valid Credentials

Depending on the endpoint you are logging into, you will need to specify the Tenant Organization

administrator@system would be the username for the default administrator

Valid REST Headers

These are the headers you specify so that the Cloud Director knows what type information to expect, or what type of information you want in return.

Accept - What type of information do you want from the Server.

Content-Type - What type of information are you planning on sending.

Valid API Version

For each Major Version of Cloud Director, there is a corresponding API Version.

Like with the Major Version of the Product, an API Version will also go end of life.

Along with a Version being active, there are also some functions that are only possible on later Versions of the API.

As of 10.4, 37.0 is the latest, non-beta version of the API

Login Session

Like with the UI, each User will need to authenticate with the API.

Once authenticated, you are presented with a Token which allows you to run API Calls until that Token expires.

Token for Subsequent API Calls

The most common API Token is generated via an API Login Session

Starting with 10.3.1, it is possible to create an API Access Token which is beneficial for automation as they do not expire.

https://docs.vmware.com/en/VMware-Cloud-Director/10.4/VMware-Cloud-Director-Tenant-Portal-Guide/GUID-A1B3B2FA-7B2C-4EE1-9D1B-188BE703EEDE.html

cURL

This is the one of the most basic REST Clients that will allow you to connect to Cloud Director and run API calls.

Locate and choose a Valid API version.
curl -ksSL -D - -X GET https://$HOSTNAME/api/versions

<VersionInfo deprecated="false">    ## This indicates whether there is a plan to remove or not
<Version>37.0</Version>       ## 37.0 is the version in this instance

Create a Login Session
curl -ksSL -D - -X POST https://VCD_FQDN/cloudapi/1.0.0/sessions/provider -H "Accept: application/json;version=37.0" -u "administrator@system:<Password>"

We are using the Accept Header i.e. communicate to us using JSON and use API Version 37.0.

/sessions/provider is the provider login endpoint

/sessions would be the tenant login endpoint

user@tenant is the username format for a tenant login

As part of the output, you will receive a set of Response Headers, one of which will be

X-VMWARE-VCLOUD-ACCESS-TOKEN: <Unique String>

Unique String is usually several lines long.

This is the Token for Subsequent API Calls specified above.

Authorization: Bearer <Unique String>

Subsequent API Example - Cross Origin Resource Sharing (Cors) Settings
curl -ks -X GET "https://VCD_FQDN/cloudapi/1.0.0/site/settings/cors?page=1&pageSize=25" -H "Accept: application/json;version=37.0" -H "Authorization: Bearer <Unique String>"

Note we no longer provide the Credentials.

If you needed to modify data, you would use another API Method

PUT - Update an existing object

POST - Create a new Object

DELETE - Delete an existing Object

If you are sending data to the Server you would need additional headers such as Content-Type already mentioned.

For APIs that use /cloudapi/ such as CORS above, the Content-Type has to be JSON.

If you wish to use any other Rest Client, it is simply a process of identifying where to place the requested information.

Depending on the Client, they may have the ability to replay or save previously run calls, or in some instances have the ability to simplify the login process.

POSTMAN would be a good example for a REST Client which makes the process easier, whilst still exposing the requirements.

PowerCLI is a wrapper for API Calls, and as such hides a lot of the basics from the end user, making the process extremely straight forward but it not transferrable to other methods.

If you can run cURL or Postman, you will understand what PowerCLI is looking to achieve.

Whereas if you have only every run PowerCLI, you may not know what is going on underneath.

Related Information

OpenAPI Documention for Sessions

https://vdc-download.vmware.com/vmwb-repository/dcr-public/772aa4c5-7e61-4d80-8432-b8e0d821c969/2747ec83-6aef-4560-b1d1-55ed9adc4e73/vcd-openapi-docs.html#api-Sessions-providerLogin

PowerCLI Cloud Director Cmdlet Reference Guide

https://developer.vmware.com/docs/powercli/latest/products/vmwareclouddirector/

Detectable by VMware SkylineTM

Actions

Copy

link to clipboard
copied!

Print

Language:
Chinese (Simplified)JapaneseEnglish

Attachments

Additional Resources

No results for undefined

Ask The Community

Get answers quickly from VMware experts in the community

Post Subject

CONTINUE IN COMMUNITIES

Related Products:

VMware Cloud Director for Service Provider

VMware Cloud Director

Related Versions:

VMware Cloud Director for Service Provider 9.x

VMware Cloud Director for Service Provider 8.x

Take Our Survey

Support Assistant