I am trying to update start date on service already assigned to a user.
my script uses:
$ServicesApiUrl = “admin/customers/customer/$CustomerId/internet-services?” . http_build_query($search);
$result = $api->api_call_put($ServicesApiUrl, $ServiceId,
array(
'start_date' => substr($date, 0, -9),
));
This gives me an error 422 and says I must specify ‘login’ ‘status’ ‘quantity’ ‘description’ and 'tariff_id’
If I go ahead and set these attributes it creates a new service for the customer instead of updating the existing one.
how can I update existing service?
Nik
July 11, 2017, 7:27am
2
Hi Rob,
to update services you should use next URL:
$ApiUrlCust = "admin/customers/customer";
$curent_customer = 1; //customer id
$curent_service = 1; //service id
$data_array = array(
'start_date' => substr($date, 0, -9) //
);
$result = $api->api_call_put($ApiUrlCust.'/'.$curent_customer."/internet-services--{$curent_service}",'', $data_array);
Thanks Nikolay
I have it working now
Could you possibly help with syntax for getting the service ID from a API get request and assigning it to a variable that I could call in my update like your example above.
I tried something like this but it doesn’t work:
print “Get Services\n”;
$result = $api->api_call_get($ServicesApiUrl);
print "Result: ";
if ($result) {
print “Ok!\n”;
print_r($api->response[0]);
$current_service = $api->response[0]->id;
} else {
print “Fail! Error code: $api->response_code\n”;
print_r($api->response);
$current_service = false;
}
print “\n-------------------------------------------------\n”;
Nik
July 13, 2017, 6:06am
4
Rob_West:
print “Get Services\n”;
$result = $api->api_call_get($ServicesApiUrl);
print "Result: ";
if ($result) {
print “Ok!\n”;
print_r($api->response[0]);
$current_service = $api->response[0]->id;
} else {
print “Fail! Error code: $api->response_code\n”;
print_r($api->response);
$current_service = false;
}
print “\n-------------------------------------------------\n”;
just one small mistake:
$current_service = $api->response[0]['id'];
Ahh thank you Nikolay, I thought I tried that already but just tried it again and it worked.