I want to undeploy a vApp using the Java APIs. The vApp was created in a different program using the Java APIs. The same user ID is used to log in in both programs. However, when I try to execute undeploy(UndeployPowerActionType.Force).waitForTask(0), I get the Access_to_Resource_is_forbidden_error. I modeled my program after the HellovCloud sample program. Here is the flow:
vcloudClient.login();
org = Organization.getOrganizationByReference()
vdcRef = org.getVdcRefByName()
vdc = Vdc.getVdcByReference()
vappRefs = vdc.getVappRefs()
vapp = Vapp.getVappByReference()
vapp.undeploy(UndeployPowerActionType.FORCE).waitForTask(0). // ACCESS_TO_RESOURCE_IS_FORBIDDEN
I am able to execute "vapp.powerOff().waifForTask(0)" before the undeploy. However I get the undeploy error whether I first powerOff the vapp or not.
Any ideas on why this is occurring and how to overcome it? I'm using vCloud Director 5.1. Thanks very much.