function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
LeoLiLeoLi 

How can I remove the empty Package with SOAP API?

I'm writing code to deploy and remove my sample package with Metadata API File-Based Calls. The code can works well but I still meet a problem:
Because of I specifiy the fullName in the package.xml file, after the code deployed, there will be a new Package created in the package list.
But after I removed the all of the source code with destructiveChanges.xml file, I noticed that the empty package still be there.

I tried to use other Metadata APIs to enumerate the created package list, but I always fails. Then I checked with the describeMetadata() API, I noticed that only InstalledPackage exists, no metadata type called Package in my DE.

But I still eager to know how could I remove the created package by code? Any one meets the same problem as me?
pconpcon
Can you provide the package.xml and the destructiveChanges.xml you have tried to remove the package?  As well as the call you make to create the package?
LeoLiLeoLi
pcon, thanks for your reply.
Seems I could not attach these two files here, so I just post the contents of these two files here
Here is the content for the destructiveChanges.xml file
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
  <fullName>Package Sample Name</fullName>
  <types>
    <members>ApexPage1</members>
    <members>ApexPage2</members>
    <name>ApexPage</name>
  </types>
  <types>
    <members>ApexPage1Controller</members>
    <members>ApexPage1ControllerTest</members>
    <members>ApexPage2Controller</members>
    <members>ApexPage2ControllerTest</members>
    <name>ApexClass</name>
  </types>
  <version>35.0</version>
</Package>
And here is the content for the package.xml
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <version>35.0</version>
</Package>
I package them into a zip file and I use the deploy() File based Metadata API to remove the package that I deployed.

Anything was wrong with the files?
pconpcon
Have you tried providing the InstalledPackage name in your destructive changes xml?  According to the docs it has to be done by itself
 
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
  <fullName>Package Sample Name</fullName>
  <types>
    <members>PackageName</members>
    <name>InstalledPackage</name>
  </types>
  <version>35.0</version>
</Package>
LeoLiLeoLi
Thanks for your suggestion pcon, but seems it does not works.
I deloy the package with deploly() API, too, with the fullName specified in the package.xml.
So the code will appear at "Create > Packages" but not the InstalledPackage.