VMware {code} Community
JohnSpielberg
Contributor
Contributor

How to retrieve list of tasks using vCenter API v7.0.3

Although I've read the official documentation for vCenter API but I find it a little bit complex to understand, 
I'm trying to call the vCenter API using below steps:

first I send a GET request to https://{api_host}/api/vapi/metadata/metamodel/service in order to get a list of all the valid service object names in my environment, in my case I added:

 

"com.vmware.vcenter.VM"

 

So the body of my request looks like this:

 

 

 

{
  "filter_spec": {
    "services": [
      "com.vmware.vcenter.VM"
    ]
  }
}

 

 

 

But for the above request I get the below response:

 

 

 

{
  "error_type": "INVALID_ARGUMENT",
  "messages": [
    {
      "args": [],
      "default_message": "The arguments supplied lack TaskIds.",
      "id": "com.vmware.cis.tasksSvc.invalid.taskIds"
    }
  ]
}

 

 

 

But when I set tasks in my body of request as empty like below:

 

 

 

{
  "filter_spec": {
    "tasks": [],
    "services": [
      "com.vmware.vcenter.VM"
    ]
  }
}

 

 

 

The response is:

 

{}



I can't find what I'm doing wrong here, wonder how to retrieve list of snapshots or power tasks.

Am I missing something, Appreciate any help.

 

0 Kudos
1 Reply
artemkrim
Contributor
Contributor

have you found a solution?

0 Kudos