Requesting the HTTP POST REST API via cURL

In this example, we will create a logical switch using the HTTP POST REST API request via cURL script:

  1. Run the following cURL script from a command prompt:
curl -k -X POST https://nsxmgr-01a.corp.local/api/2.0/vdn/scopes/vdnscope-1/virtualwires -H "Accept: application/xml" -H "Content-Type: application/xml" -u admin:VMware1! -d "<virtualWireCreateSpec><name>cURL-Logical-Switch</name><description>Logical Switch created from cURL</description><tenantId>cURL Tenant</tenantId><controlPlaneMode>UNICAST_MODE</controlPlaneMode><guestVlanAllowed>false</guestVlanAllowed></virtualWireCreateSpec>" 
  1. The cURL script will return a Virtual Wire ID in this virtualwire-8 example:
  1. Verify in the vSphere Web Client ...

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.