How to filter cPanel API 2 ?
I am sending the following post request to the api
And the results are NOT filtered. I am getting :
json-api/cpanel?cpanel_jsonapi_user=andreytestdom&cpanel_jsonapi_apiversion=2&cpanel_jsonapi_module=AddonDomain&cpanel_jsonapi_func=listaddondomains&api2_filter=1&api_filter_column_0=subdomain&api_filter_term_0=andreytest134&api2_filter_type_0=containsAnd the results are NOT filtered. I am getting :
{
"cpanelresult": {
"data": [
{
"basedir": "andreytest134.eu",
"fullsubdomain": "andreytest134.andreytestdom.com",
"subdomain": "andreytest134",
"dir": "/var/home/andreytestdom/andreytest134.eu",
"domain": "andreytest134.eu",
"reldir": "home:andreytest134.eu",
"rootdomain": "andreytestdom.com",
"status": "not redirected",
"domainkey": "andreytest134_andreytestdom.com"
},
{
"dir": "/var/home/andreytestdom/newTestApiDomain.com",
"subdomain": "newtestapidomain",
"fullsubdomain": "newtestapidomain.andreytestdom.com",
"basedir": "newTestApiDomain.com",
"reldir": "home:newTestApiDomain.com",
"domain": "newtestapidomain.com",
"rootdomain": "andreytestdom.com",
"domainkey": "newtestapidomain_andreytestdom.com",
"status": "not redirected"
}
],
"module": "AddonDomain",
"event": {
"result": 1
},
"func": "listaddondomains",
"apiversion": 2,
"records_before_filter": 2
}
}-
Hello @Killy123, The filter variables for cPanel API 2 should all begin with "api2". Try updating your example to the following: json-api/cpanel?cpanel_jsonapi_user=andreytestdom&cpanel_jsonapi_apiversion=2&cpanel_jsonapi_module=AddonDomain&cpanel_jsonapi_func=listaddondomains&api2_filter=1&api2_filter_column_0=subdomain&api2_filter_term_0=andreytest134&api2_filter_type_0=contains
Let us know if this helps. Thank you.0 -
Thanks for your answer, but I still get empty data object: { "cpanelresult": { "event": { "result": 1 }, "records_before_filter": 3, "module": "AddonDomain", "func": "listaddondomains", "data": [], "apiversion": 2 } }
This is the request I made :json-api/cpanel?cpanel_jsonapi_user=andreytestdom&cpanel_jsonapi_apiversion=2&cpanel_jsonapi_module=AddonDomain&cpanel_jsonapi_func=listaddondomains&api2_filter=1&api2_filter_column_0=domain&api2_filter_term_0=newtestapidomain.com &api2_filter_type_0=contains0 -
Hello, I've verified this is working on cPanel version 58 and cPanel version 60. Here's the exact URL I entered after creating xyz.tld as an addon domain name under the account: https://1.2.3.4:2083/cpsess123456789/json-api/cpanel?cpanel_jsonapi_user=cptest01&cpanel_jsonapi_apiversion=2&cpanel_jsonapi_module=AddonDomain&cpanel_jsonapi_func=listaddondomains&api2_filter=1&api2_filter_column=domain&api2_filter_term=xyz.tld&api2_filter_type=contains
Try using the code in this example, as it looks like the example you posted used a space after the domain name. I also removed the filter numerical values, as you are not using multiple filters in this scenario. Thank you.0 -
I tried everything you said, but the api still returns: { "cpanelresult": { "apiversion": 2, "func": "listaddondomains", "records_before_filter": 3, "data": [], "module": "AddonDomain", "event": { "result": 1 } } }0 -
I ran into another problem, when I am sending a request to delete an Addondomain I am sending : /json-api/cpanel?cpanel_jsonapi_user=andreytestdom&cpanel_jsonapi_apiversion=2&cpanel_jsonapi_module=AddonDomain&cpanel_jsonapi_func=deladdondomain&domain=addondomain.com&subdomain=addondomain_example.com
And I get :{ "cpanelresult": { "data": [ { "result": 0, "reason": "You do not have control of the subdomain for "addondomain.com".\n" } ], "module": "AddonDomain", "event": { "result": 1 }, "apiversion": 2, "func": "deladdondomain", "error": "You do not have control of the subdomain for "addondomain.com".\n" } }0 -
Hello, Could you open a support ticket using the link in my signature so we can take a closer look? You can post the ticket number here and I will update this thread with the outcome. Thank you. 0
Please sign in to leave a comment.
Comments
6 comments