Can not get xmlapi to work with cpanel functions.

anton_latvia

Well-Known Member
PartnerNOC
May 11, 2004
398
12
168
Latvia
cPanel Access Level
Root Administrator
Hello,
I have just started to look at xml-api, as before we were succesfully using old cpanel-10 scripts. Unfortunately I am unable to get started... Most of all I would like to use cpanel-api functions. I decided to start with list of email accounts. But when I post the following string:

/xml-api/cpanel?user=superdom
&apiversion=2
&xmlin=<cpanelaction><module>Email</module><func>listpopswithdisk</func><args></args></cpanelaction>

In return I get xml:

<?xml version="1.0" ?>
<cpanelresult>
<apiversion>1</apiversion>
<type>text</type>
<data>
<result>Access Denied to superdom.</result>
</data>
</cpanelresult>

Why is it like this? Why version is “1”? I am using latest stable build:
WHM 11.11.0 cPanel 11.15.0-C17944
CENTOS Enterprise 4.5 x86_64 on standard - WHM X v3.1.0

I tried to add <domain> variable to the argument list, but that did not make any difference. For authentication I use root and remote access hash string. Also when I try to access this script in browser I get the same result.

Small addon - I can get it working for account which is owned by root, but not for any account, owned by reseller. Why and how can I get it working for other accounts also?

So final question is: how can I make xmlapi (particularly /cpanel script) work for reseller accounts without knowing their HASH or password?

Regards,
Anton.
 
Last edited:

cPanelDavidG

Technical Product Specialist
Nov 29, 2006
11,216
12
313
Houston, TX
cPanel Access Level
Root Administrator
Hello,
I have just started to look at xml-api, as before we were succesfully using old cpanel-10 scripts. Unfortunately I am unable to get started... Most of all I would like to use cpanel-api functions. I decided to start with list of email accounts. But when I post the following string:

/xml-api/cpanel?user=superdom
&apiversion=2
&xmlin=<cpanelaction><module>Email</module><func>listpopswithdisk</func><args></args></cpanelaction>

In return I get xml:

<?xml version="1.0" ?>
<cpanelresult>
<apiversion>1</apiversion>
<type>text</type>
<data>
<result>Access Denied to superdom.</result>
</data>
</cpanelresult>

Why is it like this? Why version is “1”? I am using latest stable build:
WHM 11.11.0 cPanel 11.15.0-C17944
CENTOS Enterprise 4.5 x86_64 on standard - WHM X v3.1.0

I tried to add <domain> variable to the argument list, but that did not make any difference. For authentication I use root and remote access hash string. Also when I try to access this script in browser I get the same result.

Small addon - I can get it working for account which is owned by root, but not for any account, owned by reseller. Why and how can I get it working for other accounts also?

So final question is: how can I make xmlapi (particularly /cpanel script) work for reseller accounts without knowing their HASH or password?

Regards,
Anton.
The following works for me:
http://[B]Hostname[/B]:2086/xml-api/cpanel?user=user&apiversion=2&xmlin=<cpanelaction><module>Email</module><func>listpopswithdisk</func><args></args></cpanelaction>

Note, you can only access users that you have privileges to access. If you are a reseller, this would only be the accounts under your reseller account. If you are root, this would be all users on the server. As for why you can't access accounts not directly owned by root, I would recommend submitting a support ticket regarding that issue so that can be properly addressed.

Keep in mind, this error would also be generated if the user doesn't exist in the server.

As for the version being incorrect, apiversion tends to return 1 when an error is generated (such as in your case).
 

anton_latvia

Well-Known Member
PartnerNOC
May 11, 2004
398
12
168
Latvia
cPanel Access Level
Root Administrator
So if I use "root" and root's hash - I should be able to get access to all accounts, even owned by resellers? If so, I will open a ticket. Username I am trying to access exists and I can fetch list of accounts if I use reseller's login and hash string.

Anton

Opened new ticket: 224412
 
Last edited:

cPanelDavidG

Technical Product Specialist
Nov 29, 2006
11,216
12
313
Houston, TX
cPanel Access Level
Root Administrator
So if I use "root" and root's hash - I should be able to get access to all accounts, even owned by resellers? If so, I will open a ticket. Username I am trying to access exists and I can fetch list of accounts if I use reseller's login and hash string.

Anton
That is my understanding of the APIs as they should mimic functionality and privileges of WHM.