serreri
New Pleskian
- Server operating system version
- Debian 10
- Plesk version and microupdate number
- Plesk Obsidian Web Pro Edition Ver. 18.0.58
Hello everyone.
I generated my Api-Key in ssh and the generated key works perfectly in the Plesk REST API page, where I can
to read and create the clients.
I am using a curl script I found on this forum that is supposed to be working but on my server I can't
get it to work.
The code is this:
//-----------------------------------
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://****.com:8443/api/v2/clients');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\n \"name\": \"John Rambo\",\n \"company\": \"Crow\",\n \"login\": \"john-Crow\",\n \"status\": 0,\n \"email\": \"test@email123.com\",\n \"locale\": \"en-US\",\n \"owner_login\": \"admin\",\n \"external_id\": \"link:12345\",\n \"description\": \"Nice guy\",\n \"password\": \"Pass__Crow\",\n \"type\": \"customer\"\n}");
$headers = array();
$headers[] = 'Accept: application/json';
$headers[] = 'X-Api-Key: ********key****';
$headers[] = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
//----------------------------------
For a reason I do not understand I get no error output, but the customer is not created in my plesk.
I searched through the various forum posts but could not find a solution
Is anyone kind enough to give me a tip?
Hi thanks
I generated my Api-Key in ssh and the generated key works perfectly in the Plesk REST API page, where I can
to read and create the clients.
I am using a curl script I found on this forum that is supposed to be working but on my server I can't
get it to work.
The code is this:
//-----------------------------------
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://****.com:8443/api/v2/clients');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\n \"name\": \"John Rambo\",\n \"company\": \"Crow\",\n \"login\": \"john-Crow\",\n \"status\": 0,\n \"email\": \"test@email123.com\",\n \"locale\": \"en-US\",\n \"owner_login\": \"admin\",\n \"external_id\": \"link:12345\",\n \"description\": \"Nice guy\",\n \"password\": \"Pass__Crow\",\n \"type\": \"customer\"\n}");
$headers = array();
$headers[] = 'Accept: application/json';
$headers[] = 'X-Api-Key: ********key****';
$headers[] = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
//----------------------------------
For a reason I do not understand I get no error output, but the customer is not created in my plesk.
I searched through the various forum posts but could not find a solution
Is anyone kind enough to give me a tip?
Hi thanks