Requesting the HTTP GET REST API via cURL

In this example, we will perform an HTTP GET REST API request via cURL script:

  1. To check whether cURL is available in the operating system, use the curl ---version command.
  1. Run the following cURL script:
curl -k -X GET -H "Accept: application/xml" -H "Content-Type: application/xml" -u admin:VMware1! 'https://nsxmgr-01a.corp.local/api/2.0/services/usermgmt/user/admin' 

Here is an example output of the preceding command:

The credentials can also be input as a header, similar to Postman, with the following command:

curl -k -X GET -H "Accept: application/xml" -H "Content-Type: application/xml" -H "Authorization: ...

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.