Using mail_user_add in API call

Discussion in 'Developers' Forum' started by Bocki, Apr 18, 2023.

  1. Bocki

    Bocki Member HowtoForge Supporter

    i tried an API call with mail_user_add like so (a snippet from a bash script, I hope it is readable):
    mail_user_add "{\"session_id\":\"$session_id\",\"client_id\":\"1\",\"params\":{\"email\":\"[email protected]\",\"login\":\"[email protected]\",\"password\":\"mypassword\",\"quota\":\"0\",\"move_junk\":\"y\",\"purge_trash_days\":\"0\",\"purge_junk_days\":\"0\",\"sys_userid\":\"1\",\"sys_groupid\":\"0\"}}"
    I receive the following answer:
    {"code":"remote_fault","message":"Incorrect integer value: '' for column `dbispconfig`.`mail_user`.`sys_userid` at row 1 INSERT INTO `mail_user` (`server_id`, `email`, `login`, `password`, `name`, `quota`, `cc`, `forward_in_lda`, `sender_cc`, `maildir`, `maildir_format`, `homedir`, `uid`, `gid`, `postfix`, `greylisting`, `disablesmtp`, `disabledeliver`, `disableimap`, `disablepop3`, `autoresponder_subject`, `autoresponder_text`, `autoresponder`, `autoresponder_start_date`, `autoresponder_end_date`, `move_junk`, `purge_trash_days`, `purge_junk_days`, `custom_mailfilter`, `backup_interval`, `backup_copies`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`) VALUES ('0', '[email protected]', '[email protected]', '$6$rounds=5000$redacted', '', '0', '', 'n', '', '', 'maildir', '', '-1', '-1', 'n', 'n', 'n', 'n', 'n', 'n', '', '', 'n', NULL, NULL, 'y', '0', '0', NULL, '', '0', '', '', 'riud', 'riud', '')","response":false}
    I can insert whichever value I choose for sys_userid, it keep's failing with this error. If I omit it completely it fails asking to specify sys_userid.
    Do I do something wrong or is this a bug?
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    There is no bug, the function works fine. sys_*columns are never passed via the params array to the API. You must pass a correct client_id.
    Bocki likes this.
  3. Bocki

    Bocki Member HowtoForge Supporter

    Thanks for your super fast answer!
    Sometimes the solution is really simple and I am stupid. Currently there is no manually defined client (it's a testing environment). Therefore I should have chosen "0" as client_id, then it works. Thanks again!

Share This Page