Numerous errors during JSON API call chain

Drakula

Registered
Oct 7, 2014
3
0
1
cPanel Access Level
Root Administrator
Hello.

I use cPanel JSON API in WHM plugin. It works, but not so good as it ought to be.
I make 5 calls, but sometimes something breaks.

0. /json-api/removeacct?username=USERNAME
Response: successfully removed

wait 10s

1. /json-api/createacct?username=USERNAME&password=PASSWORD&domain=DOMAIN&cgi=0&quota=1&maxpop=0&maxftp=1&maxsql=1&useregns=0&forcedns=1&reseller=0
Bug 1 error: A database owner with the name “USERNAME” already exists

wait 10s

2. /XXX/json-api/cpanel?user=USERNAME&cpanel_jsonapi_module=Mysql&cpanel_jsonapi_apiversion=1&cpanel_jsonapi_func=adddb&arg-0=DBNAME

wait 10s

3. /json-api/cpanel?user=USERNAME&cpanel_jsonapi_module=Mysql&cpanel_jsonapi_apiversion=1&cpanel_jsonapi_func=adduser&arg-0=DB_USER&arg-1=DB_PASS

wait 10s

4. /json-api/cpanel?user=USERNAME&cpanel_jsonapi_module=Mysql&cpanel_jsonapi_apiversion=1&cpanel_jsonapi_func=adduserdb&arg-0=DBNAME&arg-1=DB_USER&arg-2=all
Bug 2 error: "You do not own the user (DB_USER)!"
I have to manually delete this user from DB.

This bug reproduces on 11.44.0 (build 30) & 11.44.1 (build 18).
Any hints appreciated.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,909
2,227
463
Hello :)

Does it make a difference if you run "/scripts/killmysqluserprivs $username" after terminating the account?

Thank you.
 

Drakula

Registered
Oct 7, 2014
3
0
1
cPanel Access Level
Root Administrator
No, i don't run "/scripts/killmysqluserprivs $username", because i call APIs from js frontend code. I'll try to make a custom cgi, which calls this script.