Hello,
I am working on a PowerShell script that interacts with a vCO workflow. I have no issues passing strings, but now I need to pass an inventory object, a vCAC blueprint object to be more precisely. But I can't figure out how to include the sdk-object information into the body of the Web request.
$body = '<execution-context xmlns="http://www.vmware.com/vco">
<parameters>
<parameter name="description" type="string">
<string>Hello vCO, I am PS</string>
</parameter>
<parameter name="blueprint" type="vCAC:Blueprint">
<sdk-object> href="https://XXXXXX:8281/api/catalog/vCAC/Blueprint/59a8b719-b5b6-4676-acaa-f9c89402a3c5%252Ffad8e332-0c5..." id="59a8b719-b5b6-4676-acaa-f9c89402a3c5/fad8e332-0c5b-4110-a7c8-58890e246d48" </sdk-object>
</parameter>
</parameters>
</execution-context>'
Invoke-WebRequest -uri https://XXXXXX:8281/api/workflows/516bb2af-213e-420e-9d93-b2babcdd5621/executions/ -Headers $headers -Body $body -ContentType "application/xml" -Method Post
Invoke-WebRequest : HTTP Status 409 - Parameter of type: vCAC:Blueprint did not have objectRef or id.
type Status report
message Parameter of type: vCAC:Blueprint did not have objectRef or id.
description The request could not be completed due to a conflict with the current state of the resource.
VMware vFabric tc Runtime
Any help on how to pass the object reference to the Web Request is appreciated.
Regards,
Juan.
Hello Juan, you're going to hate how close you are
You closed off the sdk-object tag when you weren't supposed to... Compare your body to this one that works for me:
<execution-context xmlns="http://www.vmware.com/vco">
<parameters>
<parameter type="vCAC:Blueprint" name="blueprint" scope="local">
<sdk-object type="vCAC:Blueprint" href= "https://vcac-l-01a.corp.local:8281/vco/api/catalog/vCAC/Blueprint/f2b5ed9f-e27b-4426-bec9-26096db9c9..." id="f2b5ed9f-e27b-4426-bec9-26096db9c944/53e28bd5-b640-4a9f-9715-09fa36c20ad7"/>
</parameter>
</parameters>
</execution-context>
Note that the <sdk-object tag has all the properties that define the object you are calling....
So your code should actually be:
<execution-context xmlns="http://www.vmware.com/vco">
<parameters>
<parameter name="description" type="string">
<string>Hello vCO, I am PS</string>
</parameter>
<parameter name="blueprint" type="vCAC:Blueprint" scope="local">
<sdk-object href="https://XXXXXX:8281/api/catalog/vCAC/Blueprint/59a8b719-b5b6-4676-acaa-f9c89402a3c5%252Ffad8e332-0c5..." id="59a8b719-b5b6-4676-acaa-f9c89402a3c5/fad8e332-0c5b-4110-a7c8-58890e246d48" />
</parameter>
</parameters>
</execution-context>
Message was edited by: Burke Azbill - Added corrected XML for original post...
Hello Juan, you're going to hate how close you are
You closed off the sdk-object tag when you weren't supposed to... Compare your body to this one that works for me:
<execution-context xmlns="http://www.vmware.com/vco">
<parameters>
<parameter type="vCAC:Blueprint" name="blueprint" scope="local">
<sdk-object type="vCAC:Blueprint" href= "https://vcac-l-01a.corp.local:8281/vco/api/catalog/vCAC/Blueprint/f2b5ed9f-e27b-4426-bec9-26096db9c9..." id="f2b5ed9f-e27b-4426-bec9-26096db9c944/53e28bd5-b640-4a9f-9715-09fa36c20ad7"/>
</parameter>
</parameters>
</execution-context>
Note that the <sdk-object tag has all the properties that define the object you are calling....
So your code should actually be:
<execution-context xmlns="http://www.vmware.com/vco">
<parameters>
<parameter name="description" type="string">
<string>Hello vCO, I am PS</string>
</parameter>
<parameter name="blueprint" type="vCAC:Blueprint" scope="local">
<sdk-object href="https://XXXXXX:8281/api/catalog/vCAC/Blueprint/59a8b719-b5b6-4676-acaa-f9c89402a3c5%252Ffad8e332-0c5..." id="59a8b719-b5b6-4676-acaa-f9c89402a3c5/fad8e332-0c5b-4110-a7c8-58890e246d48" />
</parameter>
</parameters>
</execution-context>
Message was edited by: Burke Azbill - Added corrected XML for original post...
Yes, I guest I was close, but is tricky sometimes to get the format of the request right. Thanks a lot!