Hi, I've been trying to make an api call in php to delete a client using its client id, but it's not working even though I've checked as many resources available as possible.
The PHP code I'm using is:
$query=$email;
$response = $api->get("clients", "search", array('query'=>$query));
$client = $response->response();
$response_decoded = $response->response();
echo "\n".json_encode($response_decoded);
$client = $client[0];
$user_id = intval($client->id_value);
echo "<br>Client ID: $user_id"; //outputs "4983" (client id of the client account I'm using for testing)
$response = $api->delete("clients", "delete", array($user_id));
print_r($api);
$response_decoded = $response->response();
echo json_encode($response_decoded);
And it's returning the following error:
"Too few arguments to function Clients::delete(), 0 passed in \/path\/to\/blesta\/installation\/app\/controllers\/api.php on line 154 and exactly 1 expected
However, print_r($api) prints:
BlestaApi Object
(
[url:BlestaApi:private] => api_url
[user:BlestaApi:private] => api_user
[key:BlestaApi:private] => api_key
[last_request] => Array
(
[url] => https://path/to_blesta/api/clients/delete.json
[args] => Array
(
[0] => 4983
)
)
)
So it seems that there is indeed an argument passed.
The API Docs, in Clients Class, say:
I've tried passing the $user_id (client id) without using an array, but another error suggests to use an array.
What am I doing wrong? I've used the api for other cases and following the API docs all worked fine.