How it works...

In this example, we made HTTP GET and HTTP POST requests using functions from the Requests Python module. To use the functions, we import the module first by adding the import requests at the beginning of a code.

The required values, such as the FQDN or IP of NSX Manager, URL, headers, and credentials, are stored in variables so they can be reused:

nsxmanager = 'https://nsxmgr-01a.corp.local'nsxurl = '/api/2.0/services/usermgmt/user/admin'nsxheaders = {'Content-Type': 'application/xml'}nsxuser = 'admin'nsxpass = 'VMware1!'
  • For making an HTTP GET request, we used the request.get function, and for making an HTTP POST request, we used request.post imported from the requests library.
  • The HTTP request is then stored on a variable ...

Get VMware NSX Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.