rlmitchell
Contributor
Contributor

vCD 1.5 api/admin/extension/blockingTask

Hi all,  I'm having a problem with POSTing to fail/abort a blocking task with the REST API.   Anyone know why I'm getting the exception?  Am I doing it wrong?  Thanks in advance!
1) get the authentication token
x-vcloud-authorization: b72QR5JxAFPp9Od48nRzZDX2JoBiY7g1PcwhttmnFNk=
2) list blocking tasks
curl -v --insecure -H "x-vcloud-authorization: b72QR5JxAFPp9Od48nRzZDX2JoBiY7g1PcwhttmnFNk=" $vcloudurl -X GET https://VCLOUDDIRECTORHOST/api/admin/extension/blockingTasks
<?xml version="1.0" encoding="UTF-8"?>
    <vcloud:Link rel="up" type="application/vnd.vmware.admin.vmwExtension+xml" href="https://VCLOUDDIRECTORHOST/api/admin/extension"/>
    <vcloud:Reference type="application/vnd.vmware.admin.blockingTask+xml" name="vdcComposeVapp" href="https://VCLOUDDIRECTORHOST/api/admin/extension/blockingTask/edadb0c5-f636-4cee-b728-a080292e7fef"/>
    <vcloud:Reference type="application/vnd.vmware.admin.blockingTask+xml" name="vdcComposeVapp" href="https://VCLOUDDIRECTORHOST/api/admin/extension/blockingTask/fd75cf56-81ee-47ce-9721-826ce1627bc1"/>
    <vcloud:Reference type="application/vnd.vmware.admin.blockingTask+xml" name="vdcComposeVapp" href="https://VCLOUDDIRECTORHOST/api/admin/extension/blockingTask/a6d3519c-14cb-4dea-846f-b93a129dd081"/>
    <vcloud:Reference type="application/vnd.vmware.admin.blockingTask+xml" name="vdcComposeVapp" href="https://VCLOUDDIRECTORHOST/api/admin/extension/blockingTask/6eec031a-bd52-4c8e-b62b-0646961fb56a"/>
    <vcloud:Reference type="application/vnd.vmware.admin.blockingTask+xml" name="vdcComposeVapp" href="https://VCLOUDDIRECTORHOST/api/admin/extension/blockingTask/e5839e47-0d0b-4b43-9ca1-2676eee55c33"/>
    <vcloud:Reference type="application/vnd.vmware.admin.blockingTask+xml" name="vappDeploy" href="https://VCLOUDDIRECTORHOST/api/admin/extension/blockingTask/5ad5c7ea-415c-41b1-b16c-1f2b8c34a05f"/>
    <vcloud:Reference type="application/vnd.vmware.admin.blockingTask+xml" name="vdcComposeVapp" href="https://VCLOUDDIRECTORHOST/api/admin/extension/blockingTask/2b8596ee-7a18-409d-b170-fe407a8cb986"/>
    <vcloud:Reference type="application/vnd.vmware.admin.blockingTask+xml" name="vdcDeleteVapp" href="https://VCLOUDDIRECTORHOST/api/admin/extension/blockingTask/c4e1c8a9-a644-4904-b3cd-16a28ab3139f"/>
    <vcloud:Reference type="application/vnd.vmware.admin.blockingTask+xml" name="vdcComposeVapp" href="https://VCLOUDDIRECTORHOST/api/admin/extension/blockingTask/9d896aaf-30ac-4478-b7ef-5741e19cb032"/>
    <vcloud:Reference type="application/vnd.vmware.admin.blockingTask+xml" name="vdcComposeVapp" href="https://VCLOUDDIRECTORHOST/api/admin/extension/blockingTask/10a1f856-525c-4391-b663-4b9ad9f2a803"/>
    <vcloud:Reference type="application/vnd.vmware.admin.blockingTask+xml" name="vdcDeleteVapp" href="https://VCLOUDDIRECTORHOST/api/admin/extension/blockingTask/e149b89c-1a8b-4f7b-b8b8-d822776d6c18"/>
    <vcloud:Reference type="application/vnd.vmware.admin.blockingTask+xml" name="vdcComposeVapp" href="https://VCLOUDDIRECTORHOST/api/admin/extension/blockingTask/1bb4d4f6-af19-48c8-bc40-ef25dd9e0f2b"/>
    <vcloud:Reference type="application/vnd.vmware.admin.blockingTask+xml" name="vdcComposeVapp" href="https://VCLOUDDIRECTORHOST/api/admin/extension/blockingTask/1f3b4dd3-9332-4113-8cf1-06a9a54f501d"/>
    <vcloud:Reference type="application/vnd.vmware.admin.blockingTask+xml" name="vappDeploy" href="https://VCLOUDDIRECTORHOST/api/admin/extension/blockingTask/8b545b45-ab51-4403-8ded-4c73a40c0513"/>
    <vcloud:Reference type="application/vnd.vmware.admin.blockingTask+xml" name="vdcComposeVapp" href="https://VCLOUDDIRECTORHOST/api/admin/extension/blockingTask/688b8514-eb55-4aab-a718-d6febbffd589"/>
</vmext:BlockingTaskReferences>
3) get blocking task url
mitchelr@M90p:~$ curl -v --insecure -H "x-vcloud-authorization: b72QR5JxAFPp9Od48nRzZDX2JoBiY7g1PcwhttmnFNk=" $vcloudurl -X GET https://VCLOUDDIRECTORHOST/api/admin/extension/blockingTask/1f3b4dd3-9332-4113-8cf1-06a9a54f501d
<?xml version="1.0" encoding="UTF-8"?>
<vmext:BlockingTask xmlns:vmext="http://www.vmware.com/vcloud/extension/v1.5" xmlns:vcloud="http://www.vmware.com/vcloud/v1.5" status="active" timeoutDate="2011-11-13T10:48:05.764-06:00" timeoutAction="abort" createdTime="2011-11-08T10:48:05.764-06:00" name="vdcComposeVapp" id="urn:vcloud:blockingTask:1f3b4dd3-9332-4113-8cf1-06a9a54f501d" type="application/vnd.vmware.admin.blockingTask+xml" href="https://VCLOUDDIRECTORHOST/api/admin/extension/blockingTask/1f3b4dd3-9332-4113-8cf1-06a9a54f501d" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/extension/v1.5 http://10.9.184.100/api/v1.5/schema/vmwextensions.xsd http://www.vmware.com/vcloud/v1.5 http://10.9.184.100/api/v1.5/schema/master.xsd">
    <vcloud:Link rel="resume" type="application/vnd.vmware.admin.blockingTaskOperationParams+xml" href="https://VCLOUDDIRECTORHOST/api/admin/extension/blockingTask/1f3b4dd3-9332-4113-8cf1-06a9a54f501d/act..."/>
    <vcloud:Link rel="abort" type="application/vnd.vmware.admin.blockingTaskOperationParams+xml" href="https://VCLOUDDIRECTORHOST/api/admin/extension/blockingTask/1f3b4dd3-9332-4113-8cf1-06a9a54f501d/act..."/>
    <vcloud:Link rel="fail" type="application/vnd.vmware.admin.blockingTaskOperationParams+xml" href="https://VCLOUDDIRECTORHOST/api/admin/extension/blockingTask/1f3b4dd3-9332-4113-8cf1-06a9a54f501d/act..."/>
    <vcloud:Link rel="updateProgress" type="application/vnd.vmware.admin.blockingTaskUpdateProgressOperationParams+xml" href="https://VCLOUDDIRECTORHOST/api/admin/extension/blockingTask/1f3b4dd3-9332-4113-8cf1-06a9a54f501d/act..."/>
    <vcloud:Link rel="up" type="application/vnd.vmware.vcloud.task+xml" href="https://VCLOUDDIRECTORHOST/api/task/a0dc5e18-c9ab-4542-844b-4dfeaa05f877"/>
    <vcloud:Organization type="application/vnd.vmware.admin.organization+xml" name="itdev1" href="https://VCLOUDDIRECTORHOST/api/admin/org/f300c1de-ce2c-417e-9525-f797642f1dae"/>
    <vcloud:User type="application/vnd.vmware.admin.user+xml" name="biscuits" href="https://VCLOUDDIRECTORHOST/api/admin/user/51a1af44-3c08-4114-82b6-e5a0900a2e64"/>
    <vcloud:TaskOwner type="application/vnd.vmware.vcloud.vApp+xml" name="" href="https://VCLOUDDIRECTORHOST/api/vApp/vapp-9ed3a685-c446-447f-92d5-554766a14f90"/>
</vmext:BlockingTask>
4) abort blocking task with POST call
mitchelr@M90p:~$ curl -v --insecure -H "x-vcloud-authorization: b72QR5JxAFPp9Od48nRzZDX2JoBiY7g1PcwhttmnFNk=" $vcloudurl -X POST
<ns1:XMLFault xmlns:ns1="http://cxf.apache.org/bindings/xformat"><ns1:faultstring xmlns:ns1="http://cxf.apache.org/bindings/xformat">java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.WildcardTypeImpl cannot be cast to java.lang.Class</ns1:faultstring></ns1:XMLFault>
0 Kudos
5 Replies
rkamal
VMware Employee
VMware Employee

Hi,

The blocking task's POST action operations like resume/abort/fail requires XML body to be sent along with the POST operation.

Ex: POST - action/abort

      POST XML Body - BlockingTaskOperationParamsType

      POST Content-Type - application/vnd.vmware.admin.blockingTaskOperationParams+xml

I think you are missing the POST XML Body and Content-Type.

Regards,

Rajesh Kamal.

rlmitchell
Contributor
Contributor

Thanks!

mitchelr@M90p:~$ curl --insecure -H "x-vcloud-authorization: b72QR5JxAFPp9Od48nRzZDX2JoBiY7g1PcwhttmnFNk=" -H "Content-Type: text/xml"  $vcloudurl -X POST https://VCLOUDDIRECTORHOST/api/admin/extension/blockingTask/1f3b4dd3-9332-4113-8cf1-06a9a54f501d/act... -d "<?xml version=\"1.0\" encoding=\"UTF-8\"?><BlockingTaskOperationParams xmlns=\"http://www.vmware.com/vcloud/extension/v1.5\" ><Message>Approved by system administrator.</Message></BlockingTaskOperationParams>"

now gives me:

<Error xmlns="http://www.vmware.com/vcloud/v1.5" stackTrace="javax.ws.rs.WebApplicationException

....

....

minorErrorCode="UNSUPPORTED_MEDIA_TYPE" message="Unsupported Media Type" majorErrorCode="415" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://10.9.184.100/api/v1.5/schema/master.xsd"></Error>

Is there a document that describes what the XML post needs to be?  I can't seem to find an example as of yet.

Thanks!!

0 Kudos
rkamal
VMware Employee
VMware Employee

Hi,

http://www.vmware.com/pdf/vcd_15_api_guide.pdf Pg 231.

You are misssing the Content-Type :

Content-Type: application/vnd.vmware.admin.blockingTaskOperationParams+xml
Rregards,
Rajesh Kamal.
rlmitchell
Contributor
Contributor

Many Thanks!

0 Kudos
rlmitchell
Contributor
Contributor

Apologies, I completely overlooked it...

0 Kudos