Skip to content

Instantly share code, notes, and snippets.

@goneri
Created April 24, 2020 15:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goneri/93af017a686bd7be39c411d31f92c533 to your computer and use it in GitHub Desktop.
Save goneri/93af017a686bd7be39c411d31f92c533 to your computer and use it in GitHub Desktop.
Example of interaction with a vCenter with curl and the REST API.
#!/bin/bash
server='https://vcenter.test'
password='z!Zq4Y&`/!E(o<br?:L>'
session_id=$(curl -q -X POST -k -u "administrator@vsphere.local:${password}" ${server}/rest/com/vmware/cis/session|jq -r .value)
for i in $(seq 10); do
curl -ik -H 'Accept:application/json' -H "vmware-api-session-id:${session_id}" -X GET ${server}/rest/vcenter/cluster
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment