com.vmware.vcloud.api.presentation.service.InvalidStateException: You must delete this Organization's Application Port Profiles before you can delete the organization.
This is a known issue affecting VMware Cloud Director versions 10.4.x and later.
If application port profiles are created on an edge gateway associated with an organization, attempting to delete the organization fails. The issue occurs because VMware Cloud Director deletes the edge gateways before deleting the port profiles, which causes the error.
From Cloud Director 10.3 and later versions, the stale application port profiles and this organization containing stale application port profiles can be force deleted via API.
1. Delete an organization with "force" option using API explorer:
DELETE https://<VCD-ENDPOINT>/cloudapi/1.0.0/orgs/<ORG-UUID>?force=true
2. Synchronize application port profiles:
POST https://<VCD-ENDPOINT>/cloudapi/1.0.0/applicationPortProfiles/sync
Note: POST request requires a filter to be specified. Please refer the OpenAPI documentation.
To retrieve the parameter specific to your environment, follow the steps below:
If utilization of the API is not possible then please open a support request with VMware Technical Support for assistance.
For more information on connecting to VCD via API, refer to KB 320526
This is a known issue as referenced in the following release notes: