NSX-T a.k.a NSX Cloud API tips and tricks

NSX-T has lots of interesting capabilities, but due to the rapid development and release cycle many are only available via API calls right now.

Making a request

While the NSX-T documentation has some nice examples such as:

  1. Configure an L2VPN service.

Use the POST /api/v1/vpn/l2vpn/services call.

POST /api/v1/vpn/l2vpn/services { "logical_router_id": "b6fe5455-619b-4030-b5f8-8575749f4404", "logical_tap_ip_pool" : [ "169.254.64.0/28" ], "enable_full_mesh" : true }

It doesn’t exactly hold your hand to get going.

What you’ll need is a RESTful API client like Postman from Google and some important settings:

URL:    https://<IP or FQDN of the NSX-T manager>/api/v1/vpn/l2vpn/services

(the part after /api will change depending on what call you are making)

Authorization:
Authorization: Basic Auth
Username: admin
Password: <admin password for NSX-T Manager>

Headers:
Content-Type  application/json

(this only matters when you are sending a body in the request, such as a POST request like this one.)

Body:

Raw: <Copy the sample code, modified for your environment>

That should get the request set without any “UNSUPPORTED MEDIA TYPE” or “content type not supported” messages.

Adding all the APIs as a Postman Collection

Note that you can add the NSX-T API calls as a collection into Postman by doing :

GET  https://<IP or FQDN of the NSX-T manager>/api/v1/spec/openapi/nsx_api.yaml

Select can copy all of the text in the returned body:

Then click Import in the top bar, select Paste Raw Text and paste the copied body in:

Before you click Import, scroll up ti the very top and change “host: nsxmanager.your.domain” to the FQDN of your NSX T manager.  Then click Import.

After you see the imported message

You will have a new collection listed  If you double-click on one of the requests, the request will populate with the call including the proper content type and the FQDN/IP of your NSX Manager:

 

This entry was posted in API, Cloud, Network, NSX, Virtualization, VMware and tagged , , , . Bookmark the permalink.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.