VMware Cloud Community
promiteyka1
Contributor
Contributor
Jump to solution

MimeAttachment via rest api

Hello.

I'm created a workflow with input parameters as mimeAttachment on a vRealize Orchestrator 7.

How to start this workflow with rest api by curl?

"id": "48f2f2c3-6f5f-4b1e-8b1a-f8dd74a9983d", "customized-icon": false, "name": "CreaVirtualMachineFromYaml", "version": "0.0.6", "description": "", "input-parameters": [ { "description": "Composite blueprint yaml file", "type": "MimeAttachment", "name": "file" } ] }

I'm trying this:

curl -k -1 --user username@domain.ru -X POST "https://vroserver:8281/vco/api/workflows/48f2f2c3-6f5f-4b1e-8b1a-f8dd74a9983d/executions/" -F "name=file;data=@/tmp/vm.yaml;type=MimeAttachment"

and this:

curl -k -1 --user username@billing.ru -X POST "https://vroserver:8281/vco/api/workflows/48f2f2c3-6f5f-4b1e-8b1a-f8dd74a9983d/executions/" --form "data=@/tmp/vm.yaml;type=MimeAttachment"

all my approach not working.

How do this?

Reply
0 Kudos
1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee
Jump to solution

The MimeAttachment parameter value object has the content of the mime object as byte array so I think it should be passing the content directly instead of referring to it as file. Something like the following should work

curl -ikv -u user:pass -H "Content-Type: application/json" -X POST https://10.20.30.35:8281/vco/api/workflows/1d59edd0-83c4-4d49-b987-1fb3415cdc95/executions/ -d {\"parameters\":[{\"value\":{\"mime-attachment\":{\"name\":\"mimename\",\"content\":\"aGVsbG8=\",\"mime-type\":\"text/plain\"}},\"type\":\"MimeAttachment\",\"name\":\"arg_in_0\",\"scope\":\"local\"}]}

Here, arg_in_0 is the input parameter of type MimeAttachment , and aGVsbG8= is the content value encoded in Base64 encoding (in this particular case, this is the string 'hello').

For mime attchments whose content is large and thus not possible to be passed on command line, you could put the request body in a file and invoke curl passing this file. With the above example, the file would contain

{"parameters":[{"value":{"mime-attachment":{"name":"mimename","content":"aGVsbG8=","mime-type":"text/plain"}},"type":"MimeAttachment","name":"arg_in_0","scope":"local"}]}

and the curl command line then will be (assuming the file name is request.json)

curl -ikv -u user:pass -H "Content-Type: application/json" -X POST https://10.20.30.35:8281/vco/api/workflows/1d59edd0-83c4-4d49-b987-1fb3415cdc95/executions/ -d @request.json

View solution in original post

Reply
0 Kudos
1 Reply
iiliev
VMware Employee
VMware Employee
Jump to solution

The MimeAttachment parameter value object has the content of the mime object as byte array so I think it should be passing the content directly instead of referring to it as file. Something like the following should work

curl -ikv -u user:pass -H "Content-Type: application/json" -X POST https://10.20.30.35:8281/vco/api/workflows/1d59edd0-83c4-4d49-b987-1fb3415cdc95/executions/ -d {\"parameters\":[{\"value\":{\"mime-attachment\":{\"name\":\"mimename\",\"content\":\"aGVsbG8=\",\"mime-type\":\"text/plain\"}},\"type\":\"MimeAttachment\",\"name\":\"arg_in_0\",\"scope\":\"local\"}]}

Here, arg_in_0 is the input parameter of type MimeAttachment , and aGVsbG8= is the content value encoded in Base64 encoding (in this particular case, this is the string 'hello').

For mime attchments whose content is large and thus not possible to be passed on command line, you could put the request body in a file and invoke curl passing this file. With the above example, the file would contain

{"parameters":[{"value":{"mime-attachment":{"name":"mimename","content":"aGVsbG8=","mime-type":"text/plain"}},"type":"MimeAttachment","name":"arg_in_0","scope":"local"}]}

and the curl command line then will be (assuming the file name is request.json)

curl -ikv -u user:pass -H "Content-Type: application/json" -X POST https://10.20.30.35:8281/vco/api/workflows/1d59edd0-83c4-4d49-b987-1fb3415cdc95/executions/ -d @request.json
Reply
0 Kudos