Practical NSX: Restful API

REST API allows us to programmatically control NSX, using REST API requests we can install, configure, monitor, and maintain NSX. The API calls typically use HTTP or HTTPS as the communication protocol, the payload itself is in JSON or XML format. VMware provides a beefy document that goes through all the various API calls and functionality available. If you are using NSX 6.3 like me, the guide can be found here.

There are various Rest API clients out there, in this blog post you will be using Postman which can be downloaded from here.

Once you have launched Postman, we will need to make a couple of configuration changes. Namely the Authorization type and adding a custom header which is needed for POST calls.

Configuring Postman

Launch Postman, click on Authorization, change the type to Basic, then enter your NSX Manager credentials.

Navigate to the headers menu

Add Content-Type as key and Application/xml as value

One last thing to mention here is that we will be using the https protocol to interact with the NSX manager. In my case I will be using to interact with my NSX Manager.

We are now ready to use Postman.

API Requests

Below is a list of the requests that are possible to use, however in my experience, you will find yourself using GET, POST, PUT, DELETE more frequently than the others.

GET: To read information

PUT: To update configuration.

POST: To change configuration

DELETE: To delete


Query my NSX controllers:

Query my SSO configuration:

Query my logical switches:

Create a logical switch:

As we all know, a logical switch needs to belong to a transport zone, I will therefore need to find it’s scope id as it’s part of the logical switch creation call.

Query my transport zones :

Now that we have our transport zone scope id vdnscope-1, let’s create our logical switch.

Body of our call

<description>REST API LS</description>

Checking in our NSX environment we can see that the logical has indeed been created.

Delete a logical switch

Let’s first find it’s object id: <virtualWire>


Now we can delete the logical switch:

How useful was this post?

Click on a star to rate it!

Average rating / 5. Vote count:

Sharing is caring!

Leave a Reply

Your email address will not be published. Required fields are marked *