VMware Cloud Community
etcheverri
Contributor
Contributor

Problems trying to undeploy vapp using rest api on vcloud director 9.5

Hi , i have a problem , maybe is my fault but:

i am trying to undeploy a vapp and get some weird behavior,

query : PUT https://myserver/api/vApp/vapp-somenumber/action/undeploy

with the headers:

Content-Length: 212

Content-Type: applicatapplication/vnd.vmware.vcloud.undeployVAppParams+xml; charset=ISO-8859-1

Accept: application/*+xml;version=31.0

x-vcloud-authorization: somethingsomething

with the body:

<?xml version="1.0" encoding="UTF-8"?>

<vcloud:UndeployVAppParams

    xmlns:vcloud="http://www.vmware.com/vcloud/v1.5">

    <vcloud:UndeployPowerAction> force </vcloud:UndeployPowerAction>

</vcloud:UndeployVAppParams>

and i get:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<Error

  xmlns="http://www.vmware.com/vcloud/v1.5"

  xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1"

  xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData"

  xmlns:common="http://schemas.dmtf.org/wbem/wscim/1/common"

  xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData"

  xmlns:vmw="http://www.vmware.com/schema/ovf"

  xmlns:vmext="http://www.vmware.com/vcloud/extension/v1.5"

  xmlns:ovfenv="http://schemas.dmtf.org/ovf/environment/1"

  xmlns:ns9="http://www.vmware.com/vcloud/versions" majorErrorCode="415" message="Unsupported Media Type" minorErrorCode="UNSUPPORTED_MEDIA_TYPE"/>

Any hints ? somebody? i also tried with bearer token authentication with the same error.

Reply
0 Kudos
1 Reply
patrickkuan
Contributor
Contributor

$obj_content=@"

<UndeployVAppParams xmlns="http://www.vmware.com/vcloud/v1.5">

<UndeployPowerAction>powerOff</UndeployPowerAction>

</UndeployVAppParams>

$url = 'https://myvcdfqdn/api​/vapp/{vappuuid}/action/undeploy"

$headers.'Content-Type' = "application/vnd.vmware.vcloud.undeployVAppParams+xml"

$task = Invoke-RestMethod -Uri $url -Headers $headers -Method POST -Body $obj_content  

My VCD Version is 9.7  this script(Powershell) is working. I use POST method.

Reply
0 Kudos