cPanel API access from hook with WHM 74?
Hi all,
We have a hook that let the user create a forwarder on an unexisting email address which perfectly worked until, I guess, update to version 74.
What don't work anymore is the access to cPanel API from the hook.
The code we used is the following :
But now that XML API is deprecated, we guess that we have to change *_xmlapi_* to *_jsonapi_*. But this seems not to be enough to make it work again. I guess the problem is on the call to the API but I don't find any documentation to learn what to use instead of :
Do you have some tips or the url of the documentation related to cPanel API call from hook ? Thanks in advance for any peace of information, Philippe
my $args = {
'cpanel_xmlapi_module' => 'Email',
'cpanel_xmlapi_func' => 'addpop',
'cpanel_xmlapi_apiversion' => '2',
'cpanel_xmlapi_user' => $data->{'user'},
'domain' => $domain,
'email' => $user,
'password' => '[somepass...]'
};
my $xml = Cpanel::XML::cpanel_exec_fast($args);
my $xmlRef = XML::Simple::XMLin($xml);
$logger->info(Data::Dumper::Dumper($xmlRef));But now that XML API is deprecated, we guess that we have to change *_xmlapi_* to *_jsonapi_*. But this seems not to be enough to make it work again. I guess the problem is on the call to the API but I don't find any documentation to learn what to use instead of :
my $xml = Cpanel::XML::cpanel_exec_fast($args);
my $xmlRef = XML::Simple::XMLin($xml);Do you have some tips or the url of the documentation related to cPanel API call from hook ? Thanks in advance for any peace of information, Philippe
-
Hi all, I finally found the answer after reading many different posts, but not in the cPanel documentation... use Cpanel::API; my $res = Cpanel::API::execute( 'Email', 'add_pop', { 'domain' => $domain, 'email' => $user, 'password_hash' => '$6$...', 'quota' => '500', 'skip_update_db' => 1, 'send_welcome_email' => 0 } ); $logger->info(Data::Dumper::Dumper($res));
But one question is still not answered... Is it the right way to do it ? Hope this helps those who will have the same problem. Philippe0 -
Hello @tizoo, You'll need to ensure your script makes use of the JSON output instead. We document an example of this at: UAPI - Return Data - Developer Documentation - cPanel Documentation Feel free to test out the custom code noted in your last response and let us know if you encounter any issues. Thank you. 0
Please sign in to leave a comment.
Comments
2 comments