VMware {code} Community
Franpom
Contributor
Contributor

API REST / api/vcenter/host not working

hello

I'm trying to retrieve the list of hosts on a vcenter version 7.03 via the REST API.

I identify myself via:

curl -ku administrator@vsphere.local:xxxxxxxxx -X POST https://xxxxxxx.xxxxxxxx.xx/rest/com/vmware/cis/session -H 'Content-Type: application/json'

{

"value": "efaf02a0237ca4e45b19ce1dae1680f1"

}

then I do:

curl -k -X GET https://xxxxxxx.xxxxxxxx.xx/api/vcenter/host -H 'Cookie: vmware-api-session-id=efaf02a0237ca4e45b19ce1dae1680f1' -H 'Content-Type: application/json'

{

"error_type": "INTERNAL_SERVER_ERROR",

"posts": [

{

"args": [

"com.vmware.vcenter.host.summary",

"connection_state",

"NOT_RESPONDING",

"power_state"

],

"default_message": "Structure com.vmware.vcenter.host.summary has a union constraint with tag 'connection_state' of value 'NOT_RESPONDING', for which the field 'power_state' is not allowed to be set.",

"id": "vapi.data.structure.union.extra"

}

]

}

Everything else works fine to recover cluster/datastore/vm.

Only the /api/vcenter/host API doesn't work.

Can you help me solve this problem?

Cordially

Reply
0 Kudos
1 Reply
doskiran
Enthusiast
Enthusiast

This error occurs when one of the host is in Standby Mode.

To get the Connected hosts use the below host filter API, i.e,

 

curl -k -X GET 'https://xxxxxxx.xxxxxxxx.xx/api/vcenter/host?connection_states=CONNECTED' -H 'vmware-api-session-id: efaf02a0237ca4e45b19ce1dae1680f1'

 

 

 

Reply
0 Kudos