remote api problems

Discussion in 'Installation/Configuration' started by Steffan, Jun 30, 2020.

  1. Steffan

    Steffan Member

    Hello,

    i have some problems with softacolous
    So im debugging the remote api.
    I used the examples from
    https://git.ispconfig.org/ispconfig/ispconfig3/tree/master/remoting_client

    But when adding a sql user the demoscript gives a error


    Code:
    database_error
    Incorrect integer value: '' for column `ispconfigdb`.`web_database_user`.`sys_userid` at row 1
    INSERT INTO `web_database_user` (`server_id`, `database_user`, `database_user_prefix`, `database_password`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`)
    VALUES ('7', 'db_name2', '', '*1950D0F514CDFCA9037093847748A608B091D4BE', '', '', 'riud', 'riud', '')
    
    SOAP Error: Incorrect integer value: '' for column `ispconfigdb`.`web_database_user`.`sys_userid` at row 1
    INSERT INTO `web_database_user` (`server_id`, `database_user`, `database_user_prefix`, `database_password`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`)
    VALUES ('7', 'db_name2', '', '*1950D0F514CDFCA9037093847748A608B091D4BE', '', '', 'riud', 'riud', '')
    the used code is:
    Code:
    require 'soap_config.php';
    
    
    $client = new SoapClient(null, array('location' => $soap_location,
                    'uri'      => $soap_uri,
                    'trace' => 1,
                    'exceptions' => 1));
    
    
    try {
            if($session_id = $client->login($username, $password)) {
                    echo 'Logged successfull. Session ID:'.$session_id.'<br />';
            }
    
            //* Set the function parameters.
            $client_id = 1;
            $params = array(
                    'server_id' => 7,
                    'database_user' => 'db_name2',
                    'database_password' => 'db_name2'
            );
    
            $database_user_id = $client->sites_database_user_add($session_id, $client_id, $params);
    
            echo "Database ID: ".$database_user_id."<br>";
    
            if($client->logout($session_id)) {
                    echo 'Logged out.<br />';
            }
    
    
    } catch (SoapFault $e) {
            echo $client->__getLastResponse();
            die('SOAP Error: '.$e->getMessage());
    }
    
    so i treid:
    Code:
    $params = array(
                    'server_id' => 7,
                    'database_user' => 'db_name2',
                    'database_password' => 'db_name2',
                    'sys_userid' =>  '1'
            );
    
    but again a error and sys_userid is still empty.
    So looks like sys_userid is somehow filterd?

    Any idees?
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Probably you don't have a client with ID 1 on this server.
     
  3. Steffan

    Steffan Member

    So somewhere there is a check that checks the id?
    Why is in the example then no sys_userid set.
    In the DBtable the default = 0
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    Because you passed a nonexisting client ID to the API call.
     
  5. Steffan

    Steffan Member

    Ik mean in the github example is not working. So what would be the correct code
     
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    The code you used assumes that you have a client with ID 1 on your system. But apparently, you don't have a client with that ID, so it must fail. you set the client_id in this line:

    $client_id = 1;

    so if you set a client there that does not exist, the function must fail as you can not assign a database user to a non existing client. Btw. the guys from softacolous know that, they just asked me the exact same question last week.
     
  7. Steffan

    Steffan Member

    Oke thanx.
    Ik knie that they asked, IT worked in the past in a onder server, after migration IT stopped.
    They blame ispconfig.
    In in the middle trying tot make IT work for me.

    Thanks for the answer
     
  8. till

    till Super Moderator Staff Member ISPConfig Developer

    The API in ISPConfig generally works perfectly fine, the ISPConfig Migration tool uses the exact same API and it works without issues. If you want to use that function on your system, take care to use the right variables, e.g. an existing client_id.
     

Share This Page