Skip to main content

addsubdomain API call error

Comments

4 comments

  • cPanelLauren
    Hi @swbrains I'm running this using the Command Line and not encountering any issues. Here's what I'm running: # cpapi2 --user=example SubDomain addsubdomain domain=test.example.com rootdomain=example.com --- cpanelresult: apiversion: 2 data: - reason: The subdomain "test.example.com" has been added. result: 1 event: result: 1 func: addsubdomain module: SubDomain
    I have also ensured that restrict document roots to public_html is on in tweak settings as well. I've tested with the JSON version as well: https://server.example.com:2087/cpsess2448913101/json-api/cpanel?cpanel_jsonapi_user=example&cpanel_jsonapi_apiversion=2&cpanel_jsonapi_module=SubDomain&cpanel_jsonapi_func=addsubdomain&domain=subdomain.example.com&rootdomain=example.com
    With the result: {"cpanelresult":{"data":[{"result":1,"reason":"The subdomain "subdomain.example.com" has been added."}],"apiversion":2,"module":"SubDomain","event":{"result":1},"func":"addsubdomain"}}
    Thanks!
    0
  • swbrains
    Hi, The only difference I can see between your params and mine is with the "domain" parameter value. The docs say: domain string Required The subdomain name to create. example: subdomain So in my code, I set &domain=test (for example), if I want to create test.example.com, whereas you have the full subdomain specified including the main domain its being created under. I haven't yet tried setting domain to "test.example.com" (without &dir) in my code to see if it makes a difference so I can't say if that's the difference. I've got rootdomain set as you do: example.com, which is the primary domain parked on the account. The account was created as a subdomain of my main business domain (for example, "custacct.domain.com"). Then I parked "example.com" on the customer account and tried to create the subdomain on "example.com". I doubt that all makes a difference, but I figured I'd mention it. :) Thanks!
    0
  • cPanelLauren
    Hi @swbrains I tried modifying it a bit to not include the full subdomain: https://server.example.com:2087/cpsess2448913101/json-api/cpanel?cpanel_jsonapi_user=example&cpanel_jsonapi_apiversion=2&cpanel_jsonapi_module=SubDomain&cpanel_jsonapi_func=addsubdomain&domain=test2&rootdomain=example.com
    The result: {"cpanelresult":{"func":"addsubdomain","apiversion":2,"event":{"result":1},"module":"SubDomain","data":[{"reason":"The subdomain "test2.example.com" has been added.","result":1}]}}
    Let me try it with a parked domain as well, I'll update this thread shortly. Thanks!
    0
  • cPanelLauren
    Same result for a parked domain as well: CLI: # cpapi2 --user=example SubDomain addsubdomain domain=test3 rootdomain=parkeddomain.com --- cpanelresult: apiversion: 2 data: - reason: The subdomain "test3.parkeddomain.com" has been added. result: 1 event: result: 1 func: addsubdomain module: SubDomain
    JSON https://server.lauren.tech:2083/cpsess2083998335/json-api/cpanel?cpanel_jsonapi_user=example&cpanel_jsonapi_apiversion=2&cpanel_jsonapi_module=SubDomain&cpanel_jsonapi_func=addsubdomain&domain=test4&rootdomain=parkeddomain.com
    Result: {"cpanelresult":{"module":"SubDomain","func":"addsubdomain","data":[{"result":1,"reason":"The subdomain "test4.parkeddomain.com" has been added."}],"apiversion":2,"event":{"result":1}}}
    0

Please sign in to leave a comment.