CMD_API vs CMD_ which is the preferable command to use

MaXi32

Verified User
Joined
Jul 25, 2016
Messages
645
Location
The Earth
When I read about this here https://www.directadmin.com/api.php, it clearly said that

Code:
... both CMD_POP and CMD_API_POP use the exact same code internally. If CMD_POP can do it, CMD_API_POP can do it. The only difference is the ouput. The API version will generate pareseable output."

My question is which is the preferable method to use here CMD_POP or CMD_API_POP? because sometimes I can see that CMD_API_SOMETHING does not work but CMD_SOMETHING works. Today I notice my old script that has this CMD_API_ADMIN_SETTINGS (used to work perfectly) now does not work:

Code:
cmd_api="CMD_API_ADMIN_SETTINGS"
 data="auto_update=yes&backup_threshold=90&demo_admin=no&demo_reseller=no&demo_user=no&oversell=yes&service_email_active=yes&suspend=yes&user_backup=yes&json=yes&action=save"
curl --silent --request "${method}" --user "${api_username}":"${api_password}" --data "${data}" "${ssl_protocol}://${C_BOX_HOSTNAME_FQHN}:${C_DA_PORT}/${cmd_api}"

I got the following error message:

Code:
error=1&text=You%20cannot%20execute%20that%20command&details=The%20request%20you%27ve%20made%20cannot%20be%20executed%20because%20it%20does%20not%20exist%20in%20your%20authority%20level

But, if I switch to CMD_API_ADMIN_SETTINGS to CMD_ADMIN_SETTINGS it works perfectly with the following message:

Code:
{
        "result": "",
        "success": "saved"
}

So my question to directadmin developers, which CMD_ api command you update the most in directadmin binary, the one that you recommend people to use so that, this thing won't break in the future? Should I stick with CMD_ or CMD_API ?
 
Last edited:
I got a funny solution right now for the script to select CMD_ADMIN_SETTINGS if CMD_API_ADMIN_SETTINGS is failed:


Code:
cmd_api="CMD_API_ADMIN_SETTINGS"

data="auto_update=yes&backup_threshold=90&demo_admin=no&demo_reseller=no&demo_user=no&oversell=yes&service_email_active=yes&suspend=yes&user_backup=yes&json=yes&action=save"

da_api_exec="$(curl --silent --request "${method}" --user "${api_username}":"${api_password}" --data "${data}" "${ssl_protocol}://${C_BOX_HOSTNAME_FQHN}:${C_DA_PORT}/${cmd_api}")"

not_working="$(echo "${da_api_exec}" | grep -w "You%20cannot%20execute%20that%20command")"

if [ -n "${not_working}" ]; then
# Re-execute
   cmd_api="CMD_ADMIN_SETTINGS"
curl --silent --request "${method}" --user "${api_username}":"${api_password}" --data "${data}" "${ssl_protocol}://${C_BOX_HOSTNAME_FQHN}:${C_DA_PORT}/${cmd_api}"

fi

I do hope someone in directadmin can explain the first post, so that the script that I'm using with directadmin API won't have trouble in the future.
 
Back
Top