WHM xmlApi call UAPI functions
Dears,
i would like to make a call to the new UAPI functions from the WHMapi instead of use API1 / API2 methods.
Is it possible? Do WHMapi still need to use old obsolete methods?
Can you help me?
-
WHM API and cPanel API 1/2/UAPI are separate and not callable from each other by design currently; What API call are you trying to make or task are you trying to accomplish? 0 -
WHM API can call every api1/api2 methods calling "cpanel" module. I can do everything with WHM API logged as "root". However api1/api2 are obsolete and they'll be replaced by UAPI (cPanel documentation warn to use UAPI instead API1/API2). I think this is the way. At the moment I have to: - call an api2 method to add forward - call an api1 method to del forward (which also appear to answer always 'result=1' even when i send wrong inputs). API1 & API2 methods are just old and odd. I see that uAPI have finally a standard format for vars, functions and outputs. It seems just simple and clear. However UAPI is completly useless for WHM integration if it's not callable by WHMapi 0 -
Oh good catch, I had forgotten about the cpanel module. Unfortunately I don't have a good solution to utilize cPanel UAPI directly besides calling it directly. That said, I believe you can use a combination of the single sign on session to generate a user session key and then call the UAPI call with that key. 0 -
I need to setup a single sign in order to execute every call to UAPI? This will slow down the performance of the scripts and useless add extra requests to the server. Then i'll continue to use API1/API2 calls instead of UAPI. This is bad, that function are obsolete and would be good have a internal call without use 2 signing request at time (1 for root & 1 for user). 0 -
I setupped a new feature request: [url=http://features.cpanel.net/responses/call-uapi-from-whm-api]Login Form | cPanel Feature Requests 0 -
Actually after some testing internally it might be a bug. UAPI is technically API version 3, and as such you can pass in this and it actually makes an attempt to make the correct call. Unfortunately since this system was written before UAPI it doesn't know that it should be passing the parameters as a hash instead of an array. I opened an internal case 127073 and hopefully will have the fix in 11.48. 0 -
Hi Alex, As far as I can tell, support for this doesn't exist yet, as of cPanel 11.48. The best suggestion I can offer is to create one user session, then re-use it for that user for subsequent API calls. Sessions expire 15 minutes after their most recent use. David Nielson Integration Developer, cPanel 0 -
Hi David: Thank you for your answer but could you please point me out which api commands should I use to "create user session and then re-use it". I may imagine or find them but it takes me tons of hours because the documentation is a bit messy. Thank you cPanel people for your extraordinary products. Alex 0 -
You are using the "xmlapi" call but passing "cpanel_jsonapi" arguments. The API unfortunately does not know how to parse this properly. If you want XML, use "xmlapi" and "cpanel_xmlapi" accordingly, or "jsonapi" and "cpanel_jsonapi". Here is a url I've tested on my development box that will call ModSecurity::list_domains for the user named "reseller" and return a json data structure. /json-api/cpanel?api.version=1&cpanel_jsonapi_module=ModSecurity&cpanel_jsonapi_func=list_domains&cpanel_jsonapi_user=reseller&cpanel_jsonapi_apiversion=3
Same call with xml-api that returns an xml data structure/xml-api/cpanel?api.version=1&cpanel_xmlapi_module=ModSecurity&cpanel_xmlapi_func=list_domains&cpanel_xmlapi_user=reseller&cpanel_xmlapi_apiversion=3
Your example provided cleaned up to what 'should' work (not tested)$this->object->xmlapi_query("ModSecurity", array("api.version"=>"1", "cpanel_xmlapi_user"=>"dominable", "cpanel_xmlapi_module"=>"ModSecurity", "cpanel_xmlapi_func"=>"list_domains", "cpanel_xmlapi_apiversion"=>"3" ));
Note: Support for this does exist in 11.48.0 -
Mister Hodge is correct; support for UAPI (as "API version 3") is in 11.48. I don't know what I was doing wrong before, when I couldn't get it to work, but it's working for me now. As of cPanel & WHM 11.48, it's no longer necessary to create user sessions just to make API calls on behalf of a user. 0 -
Yes, I know this is an old thread, but since I found it and it helped me after realising there were som errors in the code, I thought I'd put the working version out there if anyone else is looking for a solution to this. It works fine calling cpanel UAPI via xmlapi class from 11.48 The example cPAndrewHodge gave had only a minor error that made it not work. (ModSecurity instead of cpanel as function). This will work: $this->object->xmlapi_query("cpanel", array("api.version"=>"1", "cpanel_xmlapi_user"=>"dominable", "cpanel_xmlapi_module"=>"ModSecurity", "cpanel_xmlapi_func"=>"list_domains", "cpanel_xmlapi_apiversion"=>"3" ));
or if you prefer json:$this->object->xmlapi_query("cpanel", array("api.version"=>"1", "cpanel_jsonapi_user"=>"dominable", "cpanel_jsonapi_module"=>"ModSecurity", "cpanel_jsonapi_func"=>"list_domains", "cpanel_jsonapi_apiversion"=>"3" ));
0
Please sign in to leave a comment.
Comments
13 comments