VMware Cloud Community
Vgzsys
Contributor
Contributor
Jump to solution

API Access /api/vcenter/vm

Hello.

I'm trying to consume the API of the vcenter

Actually with administrator user, don't have acces to for example /api/vcenter/vm

https://developer.vmware.com/apis/vsphere-automation/v7.0U2/vcenter/api/vcenter/vm/get/

This endpoint is supossed to return first 4000 vms list. The error received is the typical unauthorized.

Checking the methods in order to auth, basic doesn't works , but it says something related with api_keys

https://developer.vmware.com/apis/vsphere-automation/v7.0U2/vcenter/authentication.html

Where is supposed to be created this api_key?

Thanks.

Kind regards

Labels (2)
1 Solution

Accepted Solutions
Vgzsys
Contributor
Contributor
Jump to solution

Okey.

I understand how works.

first you need to create a session id, after that can consume all apis endpoints.

 

curl -k -X POST -H "Authorization: Basic user:password(encoded base 64)" https://192.168.10.30/api/session


curl -X GET -k -H "vmware-api-session-id: session_id_returned_from_first_query" https://192.168.10.30/api/vcenter/vm

 

View solution in original post

1 Reply
Vgzsys
Contributor
Contributor
Jump to solution

Okey.

I understand how works.

first you need to create a session id, after that can consume all apis endpoints.

 

curl -k -X POST -H "Authorization: Basic user:password(encoded base 64)" https://192.168.10.30/api/session


curl -X GET -k -H "vmware-api-session-id: session_id_returned_from_first_query" https://192.168.10.30/api/vcenter/vm