API failing on 'Unknown Component ID'? - on Voice Services API call for migrating users into Splynx

Hi, new user here working though API to backfill Splynx with existing end-client info/services as we migrate off another platform. I have been trying to run the Voice Services - Create Service thru PHP (with the SplynxAPI.php library) but keep getting an HTTP 500 error back from the API call - from the Nginx level logs I’m getting it as an ‘Unknown Component ID’ but has anyone seen anything like this before? Definitely rusty at the PHP level but I know the SSL is getting through (managed to use the CDR import API OK) but I think the basic call is OK:

    //$locationsApiUrl = "admin/customers/customer/".$data_row['clientid']."/voice-service";
    $locationsApiUrl = "admin/customers/customer/9994/voice-service";
    $result = $api->api_call_post($locationsApiUrl, [
                    //'customer_id' => $data_row['clientid'],
                    'customer_id' => 9994,
                    'tariff_id' =>  16,        // for + Voicemail
                    'status' => 'active',
                    'description' => $data_row['comment'],
                    'quantity ' => 1,
                    'unit' => 0,
                    'unit_price' => 0,
                    'start_date' => '2018-01-01',
                    'end_date' => '0000-00-00',
                    'discount' => '',
                    'discount_percent' => 0,
                    'discount_start_date' => '',
                    'discount_end_date' => '',
                    'discount_text' => '',
                    'voice_device_id' => 0,
                    'phone' => $data_row['phonenum'] ] );

$data_row is coming from a MySQL instance; I’m hard coding 9994 for testing as I know that customer exists :slight_smile:

Any assistance gratefully received!

Max
New Zealand

In the nginx/splynx_err log I get

thrown in /var/www/splynx/app/di/ComponentLocator.php on line 30" while reading response header from upstream, client: X.X.X.X, server: splynx, request: “POST /api/1.0/admin/customers/customer/9994/voice-service HTTP/1.1”, upstream: “fastcgi://unix:/var/run/splynx-php5-fpm.sock:”, host: “xxx.yyy.co.nz” 2019/02/26 12:38:43 [error] 23023#23023: *289875 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught exceptions\InvalidConfig: Unknown component ID: authManager in /var/www/splynx/app/di/ComponentLocator.php:30

Stack trace:
#0 /var/www/splynx/app/BaseApp.php(345): di\ComponentLocator->get(‘authManager’)
#1 /var/www/splynx/app/web/Controller.php(216): BaseApp->getAuthManager()
#2 /var/www/splynx/app/base/Controller.php(91): web\Controller->checkAccess()
#3 /var/www/splynx/app/core/Router.php(304): base\Controller->runAction(404)
#4 /var/www/splynx/app/core/Router.php(252): core\Router->callError()
#5 /var/www/splynx/app/core/Router.php(150): core\Router->run()
#6 /var/www/splynx/app/ApiApp.php(16): core\Router->dispatchApiRequest()
#7 /var/www/splynx/web/api.php(13): ApiApp->run()
#8 {main}

Hi, try to change this:
$locationsApiUrl = “admin/customers/customer/9994/voice-service”;
to this:
$locationsApiUrl = “admin/customers/customer/9994/voice-services”;
hope this will help

1 Like

OK, my bad! (sorry) … was assuming the URL wasn’t a problem from my testing with the CDR import API - whenever I got that URL wrong I got a 403 Forbidden not a 500 Internal error there.

Thanks for your assistance!

#!/usr/bin/php
<?php
include './SplynxApi.php';
$api_url = 'http://XXX.XXX.XX.XX/'; // please set your Splynx URL
$api_key = 'your_api_key';
$api_secret = 'your_api_secret';
$api = new SplynxAPI($api_url, $api_key, $api_secret);

$locationsApiUrl = "admin/customers/customer/2/voice-services";
    $result = $api->api_call_post($locationsApiUrl,array(
                    //'customer_id' => $data_row['clientid'],
                    'customer_id' => 2,
                    'tariff_id' =>  1,        // for + Voicemail
                    'status' => 'active',
                    'description' => 'some',
                    'quantity' => 1,
                    'unit' => 0,
                    'unit_price' => 0,
                    'start_date' => '2018-01-01',
                    'end_date' => '0000-00-00',
                    'discount' => 1,
                    'discount_percent' => 2,
                    'discount_start_date' => '',
                    'discount_end_date' => '',
                    'discount_text' => '',
                    'voice_device_id' => 0,
                    'phone' => '0202020220' ));
?>

This is my script for creating voice service. Maybe it’s will be useful
And check API permissions(403 error might be as a result of incorrect API permissions)