Issue calling Bandwidth::query UAPI from WHM?
Trying to get a list of domains and their bandwidth usage, seemed like the UAPI's Bandwidth::query method was the best bet.
I am doing this server-to-server, and when I issue the call per the instructions here:
Use WHM API to Call cPanel API and UAPI - Software Development Kit - cPanel Documentation
I get this return for any request:
My request parameters are as follows:
System is running WHM 54.0 (build 28) Thanks for any insight you can offer! The docs state that the JSON response should return an integer.
{"apiversion":3,"func":"query","result":{"messages":null,"errors":null,"status":1,"metadata":{},"data":{}},"module":"Bandwidth"}My request parameters are as follows:
'cpanel_jsonapi_user' => $plan->getUsername(),
'cpanel_jsonapi_apiversion' => 3,
'cpanel_jsonapi_module' => 'Bandwidth',
'cpanel_jsonapi_func' => 'query',
'grouping' => 'domain',
'interval' => 'daily',
'protocols' => 'http',
'timezone' => 'UTC',
'start' => $start,
'end' => $end,
System is running WHM 54.0 (build 28) Thanks for any insight you can offer! The docs state that the JSON response should return an integer.
-
Hello, I just tried this out and it worked for me. I'm using WHM 62 (Build 15). Make sure $start and $end are in unix timestamp format. I got it to work with the following: [PHP] $response = $cpanel->execute_action(3, 'Bandwidth', 'query', $domainModel->getUsername(), [ 'grouping' => 'domain', 'interval' => 'daily', 'protocols' => 'http', 'timezone' => 'UTC', 'start' => strtotime('-10 days'), 'end' => time() ]); [/PHP] Notice I just went back 10 days. If I used time() for both start and end I get no data. Also, as a side comment / question. As I was reading your question I had the impression you wanted all domains on the server for your report? I wanted to confirm this only shows bandwidth for the domain (and add-on domains) for the provided cPanel username. 0 -
Hello @Saeven, cPanel version 54 is at EOL status: cPanel & WHM Version 54 Now EOL, Cent 5 & Cent 6-32bit in 3 Months | cPanel Newsroom In addition to the previous post, you may also want to upgrade cPanel to a supported version. Thank you. 0
Please sign in to leave a comment.
Comments
2 comments