Adding Vhost Alias Domain using API

Discussion in 'ISPConfig 3 Priority Support' started by pawan, Jan 11, 2021.

Tags:
  1. pawan

    pawan Member HowtoForge Supporter

    I am trying to add vhost alias domain using API, But always getting error like -

    Code:
    array(3) { ["code"]=> string(12) "remote_fault" ["message"]=> string(464) "Incorrect integer value: '' for column 'sys_userid' at row 1 INSERT INTO `web_domain` (`server_id`, `domain`, `type`, `parent_domain_id`, `redirect_type`, `redirect_path`, `ssl_letsencrypt_exclude`, `active`, `subdomain`, `seo_redirect`, `proxy_directives`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`) VALUES ('1', 'park2.mywebsolutions.co.in', 'vhostalias', '265', '', '', 'n', 'y', 'www', '', '', '', '', 'riud', 'riud', '')" ["response"]=> bool(false) } array(3) { ["code"]=> string(2) "ok" ["message"]=> string(0) "" ["response"]=> bool(true) } 
    as I could see in the example - the field/param is not there in params array - sys_userid,
    I also tried to add the same in params array, but still getting the same error.
    how I can fix it. Thanks.
     
  2. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

    You have to pass the correct sys_userid instead of a empty string.
     
  3. till

    till Super Moderator Staff Member ISPConfig Developer

    You passed a wrong client_id, the sys_userid is looked up automatically from client_id, and can not be passed to the function or params array manually.
     
    Th0m likes this.
  4. pawan

    pawan Member HowtoForge Supporter

    Hi Till,
    will the id of the client in client tab - not the client ID?
    which ID I should use for client_id?
     
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    The client_id is the ID of the client, you can find it e.g. in the client database table, it is named client_id.
     
  6. pawan

    pawan Member HowtoForge Supporter

    Hi Till,
    Yes I could see the same id I have used in client database table.
    here is the restCall I have used.
    Code:
    $result = restCall('sites_web_aliasdomain_add',['session_id' => $session_id, 'client_id'=>2, 'params'=>$params]);
     
  7. Jesse Norell

    Jesse Norell ISPConfig Developer Staff Member ISPConfig Developer

    Your first error shows you passed an empty value ('') for sys_userid, take it out of your $params as mentioned:
    Probably some of the others will need removed as well (sys_groupid, etc.).
     
  8. pawan

    pawan Member HowtoForge Supporter

    Hi Jesse,
    I used the parameters only set in example. removing any other parameter, but I am still getting the same error.
    I have double checked the client_id, it's correct.
    Here is the response I am getting.
    Code:
    array(3) { ["code"]=> string(12) "remote_fault" ["message"]=> string(466) "Incorrect integer value: '' for column 'sys_userid' at row 1 INSERT INTO `web_domain` (`server_id`, `domain`, `type`, `parent_domain_id`, `redirect_type`, `redirect_path`, `ssl_letsencrypt_exclude`, `active`, `subdomain`, `seo_redirect`, `proxy_directives`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`) VALUES ('1', 'park2.mywebsolutions.co.in', 'vhostalias', '265', '', '', 'n', 'y', 'www', '', NULL, '', '', 'riud', 'riud', '')" ["response"]=> bool(false) } 
    also can you point me to the source path where apiCall is handled?
     
    Last edited: Jan 11, 2021
  9. Jesse Norell

    Jesse Norell ISPConfig Developer Staff Member ISPConfig Developer

    The only function with that name is in the example csv mail import script.
     
  10. pawan

    pawan Member HowtoForge Supporter

    looking at the source code - I can see a function - `sites_web_vhost_aliasdomain_add`
    which correctly matches with the vhost alias domain I am trying to add.
    whereas in remoting client api doc - this function is not defined.
    is this the reason that I am getting error somewhere as I am trying to use -'sites_web_aliasdomain_add'
    Not sure please confirm.
    Update:
    If I am using 'sites_web_vhost_aliasdomain_add' function, I am getting different error-

    pm_process_idle_timeout_error_regex
    pm_max_requests_error_regex
    http_port_error_regex
    https_port_error_regex
     
    Last edited: Jan 12, 2021
  11. till

    till Super Moderator Staff Member ISPConfig Developer

    You have to pass correc t values for the mentioned fields in params array.
     
  12. pawan

    pawan Member HowtoForge Supporter

    Hi Till,
    1. As we don't need to fill up these info and default value is set, should it not work with API as well.
    2. There is no documentation or example for this API function, which parameters needs to be included.
    3. I have included the values for the mentioned fields and now I am back to square 1 and getting the same error I was getting for other function that is
      Code:
      array(3) { ["code"]=> string(12) "remote_fault" ["message"]=> string(1887) "Incorrect integer value: '' for column 'sys_userid' at row 1 INSERT INTO `web_domain`
    as for client_id, I have checked the same and value for client_id is correct, what else I need to look into, please suggest.
     
    Last edited: Jan 12, 2021
  13. till

    till Super Moderator Staff Member ISPConfig Developer

    Please see your post #10, you posted there that you solved the sys_userid error already by using the right function name now and I explained you how to solve the new error you got then.
     
  14. pawan

    pawan Member HowtoForge Supporter

    No Till, I didn't say, I resolved it, I only said, that now I am getting different error, when I include the params you suggested in the field list, I start getting the same error I was getting in the beginning, some how when I see the error, the query is trying to insert null value in sys_userid, whereas in database, this filed is defined as not null with default value of 0.
    also I have not included this field in params array, but still getting the same error.
    here is the full text of error at present which I am getting.
    Code:
    array(3) { ["code"]=> string(12) "remote_fault" ["message"]=> string(1931) "Incorrect integer value: '' for column 'sys_userid' at row 1 INSERT INTO `web_domain` (`server_id`, `ip_address`, `ipv6_address`, `domain`, `type`, `parent_domain_id`, `vhost_type`, `hd_quota`, `traffic_quota`, `cgi`, `ssi`, `suexec`, `errordocs`, `subdomain`, `ssl`, `ssl_letsencrypt`, `php`, `server_php_id`, `perl`, `ruby`, `python`, `enable_pagespeed`, `active`, `web_folder`, `redirect_type`, `redirect_path`, `seo_redirect`, `rewrite_rules`, `rewrite_to_https`, `ssl_state`, `ssl_locality`, `ssl_organisation`, `ssl_organisation_unit`, `ssl_country`, `ssl_domain`, `ssl_key`, `ssl_request`, `ssl_cert`, `ssl_bundle`, `ssl_action`, `stats_type`, `backup_interval`, `backup_copies`, `backup_excludes`, `backup_format_web`, `backup_format_db`, `backup_encrypt`, `backup_password`, `document_root`, `system_user`, `system_group`, `allow_override`, `proxy_protocol`, `php_fpm_use_socket`, `php_fpm_chroot`, `pm`, `pm_max_children`, `pm_start_servers`, `pm_min_spare_servers`, `pm_max_spare_servers`, `pm_process_idle_timeout`, `pm_max_requests`, `php_open_basedir`, `custom_php_ini`, `apache_directives`, `nginx_directives`, `proxy_directives`, `added_date`, `added_by`, `http_port`, `https_port`, `log_retention`, `jailkit_chroot_app_sections`, `jailkit_chroot_app_programs`, `delete_unused_jailkit`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`) VALUES ('1', '69.197.135.186', '2604:4300:a:191:226:6cff:fef1:dab4', 'park2.mywebsolutions.co.in', 'vhostalias', '265', 'name', '10', '1000', 'y', 'n', 'y', '1', 'www', 'n', 'n', 'php-fpm', '0', 'n', 'n', 'n', 'n', 'y', '', '', '', '', NULL, 'n', '', '', '', '', '', '', '', '', '', '', '', 'webalizer', '', '1', '', 'default', 'gzip', 'n', '', '/web/park2', 'web265', 'client2', 'All', 'n', 'n', 'n', 'ondemand', '1', '1', '1', '1', '10', '0', '/php', '', '', NULL, NULL, NULL, '', '80', '443', '30', NULL, NULL, 'n', '', '', 'riud', 'riud', '')" ["response"]=> bool(false) } 
     
  15. till

    till Super Moderator Staff Member ISPConfig Developer

    Ok, then the client_id is still wrong. Client_id can be 0, for admin user, or it miúst be a client_id for which a client exists. and client_id is not the sys_userid, so don't mix that up. The client_id is the primary ID of the client database table while sys_userid is the primary ID of the sys_user table.
     
    pawan and ahrasis like this.
  16. pawan

    pawan Member HowtoForge Supporter

    Hi Till,
    I think you are right as when I change the client_id=0, it works i.e. I am not getting the error, but I am not able to use any client_id, except client_id=0
    what could be the reason for that?
     
  17. atle

    atle Member HowtoForge Supporter

    I have exactly the same problem with invalid_system_user_or_group_txt? Did you resolve this?
    I know for sure I have the right client_id, system_user and system_group. I test with exactly the same values found in the db when I create an alias vhost via GUI.
     
  18. atle

    atle Member HowtoForge Supporter

    Of course I found the issue, I believe, right after I posted this, and several hours of debugging before that. Good, but bloody typical. Will to a test to make sure I got it right.
     
    Last edited: Feb 27, 2021
  19. atle

    atle Member HowtoForge Supporter

    Yes, I mixed up system_user/system_group with sys_userid/sys_groupid. That did solve it.
     

Share This Page