shashank

Well-Known Member
PartnerNOC
Apr 12, 2003
159
1
168
cPanel Access Level
Root Administrator
Hello People,

I have created a script which uses cpanel and WHM API functions for common Cpanel operations via a admin backend for a client using PHP. I am trying to use listfullbackups function from the backups module as per

https://documentation.cpanel.net/display/SDK/cPanel+API+2+Functions+-+Backups::listfullbackups

but I get the error as :

Code:
Could not find function 'listfullbackups' in module 'backups'
Has anyone run into the issue before ?

@CpanelDevs any idea on the fix ?
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,909
2,227
463
Hello,

Could you share the part of the code that results in this error message?

Thank you.
 

shashank

Well-Known Member
PartnerNOC
Apr 12, 2003
159
1
168
cPanel Access Level
Root Administrator
Hi,

Well the code is simple :
PHP:
$query = "https://$host:2087/xml-api/cpanel?&cpanel_xmlapi_user=$cpuser&cpanel_xmlapi_module=backups&cpanel_xmlapi_func=listfullbackups&cpanel_xamlapi_apiversion=2";

$curl = curl_init();
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,0);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER,0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER,1);
$header[0] = "Authorization: Basic " . base64_encode($login.":".$pass) . "\n\r" ;
curl_setopt($curl,CURLOPT_HTTPHEADER,$header);
curl_setopt($curl, CURLOPT_URL, $query);

$result = curl_exec($curl);
Above is the snippet how I am calling the module. It works perfectly the same way for all other modules and functions like Email, FTP etc.

Please advice.
 

shashank

Well-Known Member
PartnerNOC
Apr 12, 2003
159
1
168
cPanel Access Level
Root Administrator
Hi,

I don't think that scenario applies on my script. Here is how I am authenticating.

1. The WHM login and password is either root or the reseller user and password. This can be seen here and works for authentication just fine.
PHP:
$header[0] = "Authorization: Basic " . base64_encode($login.":".$pass) . "\n\r" ;
2. The query URL code is as below :
PHP:
$query = "https://$host:2087/xml-api/cpanel?&cpanel_xmlapi_user=$cpuser&cpanel_xmlapi_module=backups&cpanel_xmlapi_func=listfullbackups&cpanel_xamlapi_apiversion=2";
You can see I am already using cpanel_xmlapi_user as $cpuser which I am fetching as :
PHP:
$cpuser = $_GET['user'];
I am passing it via the URL as http://myurl/file.php?user=mytestuser .

Also this same logic works for all other modules like Email, FTP etc. Its just the backups module that gives the error.
 

kamall

Well-Known Member
Mar 17, 2012
46
0
56
Bethune France
cPanel Access Level
Root Administrator
Twitter
Hi,

I don't think that scenario applies on my script. Here is how I am authenticating.

1. The WHM login and password is either root or the reseller user and password. This can be seen here and works for authentication just fine.
PHP:
$header[0] = "Authorization: Basic " . base64_encode($login.":".$pass) . "\n\r" ;
2. The query URL code is as below :
PHP:
$query = "https://$host:2087/xml-api/cpanel?&cpanel_xmlapi_user=$cpuser&cpanel_xmlapi_module=backups&cpanel_xmlapi_func=listfullbackups&cpanel_xamlapi_apiversion=2";
You can see I am already using cpanel_xmlapi_user as $cpuser which I am fetching as :
PHP:
$cpuser = $_GET['user'];
I am passing it via the URL as http://myurl/file.php?user=mytestuser .

Also this same logic works for all other modules like Email, FTP etc. Its just the backups module that gives the error.
Hello
Can you connect via filezilla on port 22 or not?user and pass same as root.
Regards
Kamall;
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,909
2,227
463
Hello,

The examples you provided are not following the format listed at:

Use WHM API to Call cPanel API & UAPI

For example, this works well when I tested:

Code:
https://IP:2087/cpsess123456789/json-api/cpanel?&cpanel?api.version=1&cpanel_jsonapi_user=cptest01&cpanel_jsonapi_module=Backups&cpanel_jsonapi_func=listfullbackups&cpanel_jsonapi_apiversion=2
Does this help address the issue?

Thank you.
 

AndrewH.

Well-Known Member
Dec 10, 2012
52
3
83
cPanel Access Level
Root Administrator
To expand on why you are having issues, use "Backups" not "backups"

Good
Code:
/json-api/cpanel?cpanel_jsonapi_apiversion=2&cpanel_jsonapi_module=Backups&cpanel_jsonapi_func=listfullbackups
Code:
{"cpanelresult":{"apiversion":2,"func":"listfullbackups","data":[],"event":{"result":1},"module":"Backups"}}


Bad
Code:
/json-api/cpanel?cpanel_jsonapi_apiversion=2&cpanel_jsonapi_module=backups&cpanel_jsonapi_func=listfullbackups
Code:
{"cpanelresult":{"apiversion":2,"error":"Could not find function 'listfullbackups' in module 'backups'","func":"listfullbackups","data":{"reason":"Could not find function 'listfullbackups' in module 'backups'","result":0},"module":"backups"}}
 

shashank

Well-Known Member
PartnerNOC
Apr 12, 2003
159
1
168
cPanel Access Level
Root Administrator
Hi,

I had used Backups as the Module as well before but it did not work. However, the issue is solved now. If you check my code above. I was using "cpanel_xamlapi_apiversion" and not "cpanel_xmlapi_apiversion" . I changed to cpanel_xamlapi_apiversion and it started working.