ajtaylordev
New Pleskian
Hello, I can't work out where I am going wrong. Using the default details Plesk gave me it works fine, users, subscriptions, domain and hosting type. However when I use my own script with PHP variables in, everything is created fine except the domain hosting type is set to "No Hosting".
Working example with Plesk default details:
If anybody could tell me why my code gives me "No Hosting" as the default hosting type in comparison that would be greatly appreciated. Thankyou.
Working example with Plesk default details:
My example, same result apart from Hosting type is set to "No Hosting":// ADD SUBSCRIPTION PLAN TO CUSTOMER USING REST API CLI METHOD //
$url = 'https://example-server.cloud/api/v2/cli/subscription/call';
$payload = "{ \"params\": [\"--create\", \"example.com\", \"-owner\", \"john-unit-test\", \"-service-plan\", \"Bronze_Package\", \"-ip\", \"82.165.XXX.XXX\", \"-login\", \"john-unit-test\", \"-passwd\", \"changeme1Q**\"]}";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
$headers = array();
$headers[] = 'Accept: application/json';
$headers[] = 'Content-Type: application/json';
$headers[] = 'X-API-Key: '.$secret_token.'';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
The only thing really different is I have used single quotes in order to make the variables more readable. I doubt this causes issues as everything seems to be working like correct service plan, username, passwords etc...// ADD SUBSCRIPTION PLAN TO CUSTOMER USING REST API CLI METHOD //
$url = 'https://example-server.cloud/api/v2/cli/subscription/call';
$payload = '{ "params": ["--create", "example.com", "-owner", "'.$plesk_user.'", "-service-plan", "'.$service_plan.'", "-ip", "82.165.XXX.XXX", "-login", "'.$plesk_user.'", "-passwd", "'.$plesk_pass.'"]}';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
$headers = array();
$headers[] = 'Accept: application/json';
$headers[] = 'Content-Type: application/json';
$headers[] = 'X-API-Key: '.$secret_token.'';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
If anybody could tell me why my code gives me "No Hosting" as the default hosting type in comparison that would be greatly appreciated. Thankyou.