srkumar1986

Member
Mar 28, 2018
13
2
3
Coimbatore, Tamil Nadu
cPanel Access Level
Root Administrator
Hello,

I have some issues in calling Perl module function from WHM Plugin using uapi.

I have read the document that says to call command line and web based.

But, i have default function to load my dropdown list when form loading.
Code:
$gapp_details = $cpanel->uapi(
'GAppMod', 'load_gapp_details'
);

<select id="int_gapp_id" onchange="js:getgappdetails(this.value)">
<option selected value="0">Select Domain</option>
<?php
foreach ($gapp_details['cpanelresult']['result']['data'] as $values){
?> <option value="<?php echo $values ?>"><?php echo $values ?></option>
<?php } ?>
</select>
PS : CPanel Version v68.0.36

Appreciate your help on this please

Thanks in Advance !
Rajkumar
 
Last edited by a moderator:

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,296
1,266
313
Houston

srkumar1986

Member
Mar 28, 2018
13
2
3
Coimbatore, Tamil Nadu
cPanel Access Level
Root Administrator
Thank you Lauren,

I have one more clarification.

If any of API process needs to be run only on whm root user, Lets take an example off lets encrypt SSL Certificate process, they are guide to run this process only on root.

how i can achieve? what i should give the cpanel_jsonapi_user value?

Accessing cPanel API2 functions via WHM API

Based on the above forum details, i have given the cPanel username but it returns the error as "Permission Denied"

Any other ways please.?

Thank you!
Rajkumar S
 
Last edited by a moderator:

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,296
1,266
313
Houston
Hello,

You should be able to use the whmapi1 to call cPapi2 functions the cpanel_jsonapi_user should be the cPanel user w/no password specified. Can you show me an example of the API function you're using that's providing an error?
 

srkumar1986

Member
Mar 28, 2018
13
2
3
Coimbatore, Tamil Nadu
cPanel Access Level
Root Administrator
Hello,

You should be able to use the whmapi1 to call cPapi2 functions the cpanel_jsonapi_user should be the cPanel user w/no password specified. Can you show me an example of the API function you're using that's providing an error?
Hello,

Here is my URL for reference.
Code:
https://mydomain.com:2087/cpsess####/json-api/cpanel?api.version=1&cpanel_jsonapi_user=root&cpanel_jsonapi_module=CertificateDetails&cpanel_jsonapi_func=createcertificate&cpanel_jsonapi_apiversion=3&domain_name=mytestdomain.com
in this createcertificate i have system command to create lets encrypt ssl certificate that accessible only by root user.

But i am getting the below error

The user “root” is not associated with a cPanel account and cannot call cPanel API 2

currently the plugin is in WHM Console. By default WHM Console will execute all process as root i hope.

Please specify my mistake on this.

thanks
 
Last edited by a moderator:

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,296
1,266
313
Houston
Hello,


When running the API you shouldn't be using root as the user, you're running the command as root but the user should be the user you want to generate the certificate for. Furthermore, can you link me to the documentation of this API call, it looks like you're using a cPAPI1 function and I'd like to look at it further.


Thank you,
 

srkumar1986

Member
Mar 28, 2018
13
2
3
Coimbatore, Tamil Nadu
cPanel Access Level
Root Administrator
Hello,


When running the API you shouldn't be using root as the user, you're running the command as root but the user should be the user you want to generate the certificate for. Furthermore, can you link me to the documentation of this API call, it looks like you're using a cPAPI1 function and I'd like to look at it further.


Thank you,

Hello,

Here is my updated link

https://mydomain.com:2087/cpsess####/json-api/cpanel?api.version=1&cpanel_jsonapi_user=wpmnkme&cpanel_jsonapi_module=CertificateDetails&cpanel_jsonapi_func=createcertificate&cpanel_jsonapi_apiversion=3&domain_name=mytestdomain.com

I have changed the username as per reply.

After changing the URL, i have called the function again. But this time i had received Permission denied error.

{"func":"createcertificate","apiversion":3,"module":"CertificateDetails","result":{"errors":["\"/root/letsencrypt/./certbot-auto certonly --staging --standalone -n -d mytestdomain.com\" failed to start: \"Permission denied\" at /usr/local/cpanel/Cpanel/API/CertificateDetails.pm line 120.\n"],"status":0,"messages":null,"metadata":{},"data":null}}

The reference URL I've used as,

Use WHM API to Call cPanel API and UAPI - Developer Documentation - cPanel Documentation

Thank you!
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,296
1,266
313
Houston