SOLVED Error: Addon Domain using API2

cPanel & WHM Version
102.0.31

VeryNice

Registered
Mar 25, 2023
4
0
1
Canada
cPanel Access Level
Root Administrator
Hi!

I've been working with API version 2 to create addon domains.

I sent a POST request that looked like this: https://example.com:2083/json-api/c...example.com&dir=example.com&subdomain=example

But this is what is returned:

{
"cpanelresult": {
"module": "AddonDomain",
"event": {
"result": 1
},
"func": "addaddondomain",
"data": [
{
"result": 0,
"reason": "domain not specified"
}
],
"preevent": {
"result": 1
},
"error": "domain not specified",
"postevent": {
"result": 1
},
"apiversion": 2
}
}


Any thoughts on why this happens?

Any help is appreciated,

Thanks!
 
Last edited by a moderator:

VeryNice

Registered
Mar 25, 2023
4
0
1
Canada
cPanel Access Level
Root Administrator
Hey there! Could you try using the newer addon domain tool here instead?


The UAPI2 section hasn't been updated in some time, so you'll likely get better results from the modern system.
Hi, Yeah but that creates a Parked domain that redirects to the public_html

I assume it has to be an addon domain to direct to a separate folder.

Additional info: I just noticed I don't have root access for that specific cPanel account, Do you reckon the "domain not specified" error could potentially be because of that instead?
 

VeryNice

Registered
Mar 25, 2023
4
0
1
Canada
cPanel Access Level
Root Administrator
Ah yeah thanks, Earlier Didn't realize it was a WHM call.

But i tested it out like this: https://example.com:2087/cpsessXXXX...me=[cpanel_username]&web_vhost_domain=[vhost]

Using these parameters
Domain = Testing.com
cpanel_username = Cpanel username
Vhost = Testing.com


It returned this error:

{
"metadata": {
"result": 0,
"reason": "API failure: (XID kcqt86) “Testing.com” does not refer to any of “Cpanel Username”’s web virtual hosts.",
"command": "create_parked_domain_for_user",
"version": 1
}
}


On the API documentation, it was stated that if the Web Vhost is not the cPanel account’s main domain, then the system will consider the new domain to be an addon domain. Which it did not do, rather it returned that error.

PS. Apologies if these are noob questions, my first time using Cpanel's and WHM's API's.
 

VeryNice

Registered
Mar 25, 2023
4
0
1
Canada
cPanel Access Level
Root Administrator
Hi again!, Just figured out where I made the mistake.

The initial Addon cPanel API 2 call failed because my call:
"https://example.com:2083/js...func=addaddondomain&domain=example.com&d..."
Idk why, but it was formatted it like this
"...addaddondomain&domain=example.com..."
When it was supposed to be
"...addaddondomain&newdomain=example.com..."
No idea how messed that up, but regardless, Thanks A lot for the help!