I tried to create a API call to create a website --> Database User --> Database I create successfully the Website and Database User, now I am trying to create the Database and need to find parent_domain_id and database_user_id and I have the domain name and the user name, What is the Api call to find them? I looked in manuals and nothing found.
Started on something similar today and haven't found much good documentation. Just some very simple php examples. https://www.howtoforge.com/how-to-c...w-to-create-remote-api-scripts-for-ispconfig- https://git.ispconfig.org/ispconfig...velop/remoting_client/API-docs?ref_type=heads (down right now?) My goal is to add maildomains and https websites with several subdomains for autodiscovery/autoconfig/webmail/postfix/dovecot (last two have been made sni capable) using (curl in) a bash script from the mailserver's command line (and when it's working properly as custom command in webmin). And ofcourse first checking if domains already exists or not. For now it's just fiddling a bit to get the hang of things but saidly not getting far yet. I really need some decent documentation. I'm leaning towards sql queries to lookup stuff I need and use that in the script. Unless somebody can point to some decent api documentation.
The API returns you these ID's when you create the website and the database user. If you created them at a different time and you have them not available, you can easily look them up using the API. E.g., for the website, you look it up by domain name: Code: // Fetch by domain using a filter array: $site = $client->sites_web_domain_get($session_id, array('domain' => 'example.com')); and there you get the domain_id, which is the parent_domain_id of the database. Full example for using the API: Code: <?php $soap_location = 'https://YOUR-ISPCONFIG:8080/remote/index.php'; $soap_uri = 'https://YOUR-ISPCONFIG:8080/remote/'; $client = new SoapClient(null, array( 'location' => $soap_location, 'uri' => $soap_uri, 'trace' => 1, 'exceptions' => 1, // If you use self-signed certs in a lab: 'stream_context' => stream_context_create([ 'ssl' => ['verify_peer' => false, 'verify_peer_name' => false] ]) )); $session_id = $client->login('apiuser', 'apipass'); // Fetch by domain using a filter array: $site = $client->sites_web_domain_get($session_id, array('domain' => 'example.com')); // Or, if you already know the record ID: #$site = $client->sites_web_domain_get($session_id, 123); // primary_id print_r($site); $client->logout($session_id); And with curl, its something like this to get the session ID: Code: curl -k -s https://YOUR-ISPCONFIG:8080/remote/json.php?login \ -H 'Content-Type: application/json' \ -d '{"username":"apiuser","password":"apipass"}' And then you can e.g. query for a website like this: Code: curl -k -s 'https://YOUR-ISPCONFIG:8080/remote/json.php?sites_web_domain_get' \ -H 'Content-Type: application/json' \ -d '{"session_id":"<SESSION>","primary_id":{"domain":"example.com"}}'
Getting the session id is the only thing working from the get go. And client_get seems to be working. Everything else I tried (like mail_domain_get for example) returns nothing, while the remote user has all access.
The API is working fine as the migration tool heavily relies on it. Might be that the curl syntax is not completely right, though, as I mostly use it through SOAP, but the migration tool uses the REST version as well. If you search the forum for sites_web_domain_get, you should find some other examples. any *_get function of the API supports the search syntax, where you pass it an array with the field name and what you search for instead of a numeric primary id.
I dont use curl, prefer http request and working fine. Thank you Till for your help the last line was the hint. '{"session_id":"<SESSION>","primary_id":{"domain":"example.com"}}', "primary_id": { "database_user": "demousername" }
I tried to make a sites_web_domain_delete call with the following ways without succeed. "primary_id": { "domain_id": "455" } "primary_id": { "domain": "example.com" } Also try directly "domain_id": "455" like php sample. Do you have any instructions what "primary_id" can be?
The primary_id for the delete functions is the auto-incremented primary ID column of the matching database table, so in this case, it's the domain_id of the web_domain table.
I tried { "session_id": "hgsfgsfhshhsh", "domain_id": "123" } and have the following error "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'AND 1' at line 1 DELETE FROM `web_domain` WHERE domain_id = AND 1" I tried { "session_id": "hgsfgsfhshhsh", "primary_id": { "domain_id": "123" } } and have the following error "Unknown column 'Array' in 'WHERE' DELETE FROM `web_domain` WHERE domain_id = Array AND 1",
Have you tried: Code: {"session_id":"<SESSION>","primary_id":"123"} Because primary ID is not an array, it's a number. You can pass an array only in *_get functions to switch them to record search mode.