Tag Archives: REST

Accessing VMware vcenter REST API Authentication from curl

Here’s a simple example of calling the vSphere REST API using curl. These commands first authenticate to the API which creates a vmware-api-session-id cookie which is stored to cookie-jar.txt then makes a request to get a list of VMs:

curl -k -i -u <username>@<vcenter>:<pwd> -X POST -c cookie-jar.txt https://sc-rdops-vm12-dhcp-118-200/rest/com/vmware/cis/session
curl -k -i -b cookie-jar.txt https://<vcenter>/rest/vcenter/vm

NOTE: Use with caution as your credentials will likely be caught in your command line history!