• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Plesk 12.5 API list domains under subscription

websavers

Regular Pleskian
Hey there,

I'm working with the Plesk API for version 12.5. I'm attempting to retrieve a list of domains (including subdomains and aliases) that are found under a specified subscription, but I can't seem to figure out how to make that happen.

I first tried this type of packet:

Code:
<packet>
  <customer>
    <get-domain-list>
      ...
    </get-domain-list>
  </customer>
</packet>

Which listed all domains across all of the customer's subscriptions, however only subdomains and aliases indicated which was their parent domain. All other domains did not provide a reference to indicate what subscription they're found under, so I was unable to then filter the results manually after the XML response.

I then attempted to retrieve information about a given subscription, with the idea that it would list all of the domains under the subscription:

Code:
<packet>
<webspace>
<get>
   <filter>
      <name>primary_domain.tld</name>
   </filter>
   <dataset>
      <hosting/>
   </dataset>
</get>
</webspace>
</packet>

However that only provides me with the primary domain's hosting details and nothing about the other domains/subdomains/aliases hosted under that subscription.

So I moved on to my final option of using the <site> type packet:

Code:
<packet>
<site>
    <get>
       <filter>
           <parent-name>subscription_primary_domain.tld</parent-name>
       <dataset>
            <hosting/>
       </dataset>
    </get>
</site>

Which also fails because it only returns a single site (a subdomain, but not any of the normal domains).

UPDATE: I got this <site> request to work. The reason it was only returning a single site rather than a complete array was not the API's fault, but rather the fault of my Plesk-API library which failed to indicate in the documentation that it has a SHORT/FULL request return option that defaults to short. This means that it was automatically traversing down the XML tree to the first result and returning that value, thus cutting out all remaining results. To fix it I needed to pass a second parameter to the request() function indicating to use the FULL request format.

---

After this much testing I have the following questions:

a) Why is there no reference, particularly under the get-domain-list option, for each of the domains to their parent subscription?

b) Why do <webspace> requests not allow for a <get-all-domains> for that webspace?

c) Why does a <site> request not return more than one result when it indicates that it should? (This question is no longer valid with the UPDATE above).

a) and b) still seem like decent questions though, particularly the first one.

-Jordan
 
Last edited:
Back
Top