Skip to main content

How to filter cPanel API 2 ?

Comments

6 comments

  • cPanelMichael
    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
  • Killy123
    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=contains
    0
  • cPanelMichael
    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
  • Killy123
    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
  • Killy123
    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
  • cPanelMichael
    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.