VMware Cloud Community
jason_davis
Enthusiast
Enthusiast
Jump to solution

Force Data Collection via REST API

I am trying to execute the workflow to "Force Data Collection" via REST API.  No matter what I do, I am continuously getting Error 400.

I can run other API's in vCO, such as getting all workflows.

I assume the problem may be with the body field.  I've tried lots of different options, but cannot figure out the correct syntax to make this work.

Any suggestions would be appreciated.

cant run workflow.png

Tags (1)
Reply
0 Kudos
1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee
Jump to solution

Plug-in objects, like instances of vCAC hosts, are identifiable by their type and ID.

So assuming this workflow has an input parameter named 'host' of type vCAC:VCACHost, then the request body should look something like the following:

{

  "parameters" : [

    {

      "value": {

        "sdk-object": {

          "type" : "vCAC:VCACHost",

          "id": "cd4ed..."

        }

      },

      "type": "vCAC:VCACHost",

      "name": "host",

      "scope": "local"

    }

  ]

}

View solution in original post

Reply
0 Kudos
7 Replies
iiliev
VMware Employee
VMware Employee
Jump to solution

Plug-in objects, like instances of vCAC hosts, are identifiable by their type and ID.

So assuming this workflow has an input parameter named 'host' of type vCAC:VCACHost, then the request body should look something like the following:

{

  "parameters" : [

    {

      "value": {

        "sdk-object": {

          "type" : "vCAC:VCACHost",

          "id": "cd4ed..."

        }

      },

      "type": "vCAC:VCACHost",

      "name": "host",

      "scope": "local"

    }

  ]

}

Reply
0 Kudos
stevedrummond
Hot Shot
Hot Shot
Jump to solution

If you run into issues again trying to figure out the parameters that Illian has already answered with, the easiest way is to run the workflow manually in the vRO client and then query that workflow token using the API to inspect the parameters.

Alternatively, and you might want to do this anyway as the ID of the vCAC:Host coul change, I find it easier to create a wrapper workflow for SDK objects. In this case it would take a name of the vCAC Host as a string and the workflow looks up the SDK object (extremely easy once in vRO) which then calls the native 'Force Data collection' workflow.

Reply
0 Kudos
jason_davis
Enthusiast
Enthusiast
Jump to solution

Hi Steve,

I like the direction your proposed.  Going down this path, I manually executed my script in vRO, then I sent the API below to get the parameter

{

"href": "https://vraportal.ssilab.local:443/vco/api/workflows/3d4ad4fc-1461-47e0-ad43-59b4c431016f/executions...",

"relations":{

"link":[{"href": "https://vraportal.ssilab.local:443/vco/api/workflows/3d4ad4fc-1461-47e0-ad43-59b4c431016f/executions...",…]

},

"id": "b20dcebc-1fa1-442e-b19c-d01d9251b88c",

"state": "completed",

"start-date": "2019-02-07T17:44:23Z",

"end-date": "2019-02-07T17:44:23Z",

"started-by": "configurationadmin@vsphere.local",

"name": "Force data collection synchronous",

"current-item-for-display": "item0",

"input-parameters":[

{

"value":{

"sdk-object":{

"type": "vCAC:VCACHost",

"href": "https://vraportal.ssilab.local:443/vco/api/catalog/vCAC/VCACHost/2c3e62cb-d874-40d9-afa1-893456ff7c0...",

"id": "2c3e62cb-d874-40d9-afa1-893456ff7c0d"

}

},

"type": "vCAC:VCACHost",

"name": "host",

"scope": "local"

}

],

"output-parameters":[],

"workflow-attributes":[]

}

Then I ran a POST to

https://vraportal.ssilab.local:443/vco/api/workflows/3d4ad4fc-1461-47e0-ad43-59b4c431016f/executions...

with BODY

{

"input-parameters": [

    {

      "value": {

        "sdk-object": {

          "type": "vCAC:VCACHost",

          "href": "https://vraportal.ssilab.local:443/vco/api/catalog/vCAC/VCACHost/2c3e62cb-d874-40d9-afa1-893456ff7c0...",

          "id": "2c3e62cb-d874-40d9-afa1-893456ff7c0d"

        }

      },

      "type": "vCAC:VCACHost",

      "name": "host",

      "scope": "local"

    }

  ],

  "output-parameters": [],

  "workflow-attributes": []

}

I still get error 400, with no additional information. 

Any thoughts?

Reply
0 Kudos
jason_davis
Enthusiast
Enthusiast
Jump to solution

Ilian, thanks so much for the suggestion.  Unfortunately I couldn't make it work easily.  I am now attempting the method Steve proposed to see if I can get the syntax right.  It is not so straight forward

Reply
0 Kudos
jason_davis
Enthusiast
Enthusiast
Jump to solution

OK, I made some progress.  Actually the syntax is closer to what Ilian recommended,

When I entered the body like this

{

"parameters": [

    {

      "value": {

        "sdk-object": {

          "type": "vCAC:VCACHost",

          "href": "https://vraportal.ssilab.local:443/vco/api/catalog/vCAC/VCACHost/2c3e62cb-d874-40d9-afa1-893456ff7c0...",

          "id": "2c3e62cb-d874-40d9-afa1-893456ff7c0d"

        }

      },

      "type": "vCAC:VCACHost",

      "name": "host",

      "scope": "local"

    }

  ]

}

I get a 202 return.  And I can see the script executed.  But it failed with the following errors:'

2019-12-13 10:35:08.797] [E] Error in (Workflow:Force data collection synchronous / Scriptable task (item1)#4) java.lang.NullPointerException

[2019-12-13 10:35:08.813] [E] Workflow execution stack:

***

item: 'Force data collection synchronous/item1', state: 'failed', business state: 'null', exception: 'java.lang.NullPointerException (Workflow:Force data collection synchronous / Scriptable task (item1)#4)'

workflow: 'Force data collection synchronous' (3d4ad4fc-1461-47e0-ad43-59b4c431016f)

|  'input': name=host type=vCAC:VCACHost value=dunes://service.dunes.ch/CustomSDKObject?id='2c3e62cb-d874-40d9-afa1-893456ff7c0d'&dunesName='vCAC:VCACHost'

|  'no outputs'

|  'no attributes'

*** End of execution stack.

So it seems the script wants to know about output parameters and attributes.  But when I provide them I get and error 400

Reply
0 Kudos
jason_davis
Enthusiast
Enthusiast
Jump to solution

I finally got it working.  It seems my ID of my sdk-object was wrong.  Studying vRO i could deduce this and now the script can execute successfully

{

"parameters": [

    {

      "value": {

        "sdk-object": {

          "type": "vCAC:VCACHost",

          "id": "cd4edfad-5154-4f80-bdcc-11b902693ce4"

        }

      },

      "type": "vCAC:VCACHost",

      "name": "host",

      "scope": "local"

    }

  ]

}

Thanks all for your helpful posts

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

As you already figured out, there are some small but important differences in the body when you start an execution vs when you examine an existing execution (eg. "parameters" vs "input-parameters"/"output-parameters").

When you start a new workflow execution, you have to provide only the input parameters, using "parameters" element.

The last failure you got reports that there is a null pointer exception on the fourth (fifth, in fact) line in the scripting code of scriptable task element item1 in this workflow. To continue further, you need to check:

  • what's on this line in this particular scriptable task (this could give some ideas what could be the problem)
  • check the vRO server.log file to see if there is a Java exception trace for this error (this could point to the exact location in the code where the error is thrown)
Reply
0 Kudos