Fail updating array/object via API

Hi,

I am able to update member variables of a service using the API but the same call does not update the geo array/object.

For example, the following code updates the port_id setting but neither of the geo settings. The API response says that geo is an array, the docs say it is an object. I’ve tried setting the geo as an object, and as an array, neither works.

My code:


                $serviceApiUrl = "admin/customers/customer/".$idCustomer."/internet-services--".$idService;

                //$obj = (object) array('geo' => array('marker'=>'53,4'));

                $data_array = array(
                        'port_id' => '666', 
                        'geo' => array(
                                'address' => 'example',
                                'marker' => '57.000000, -3.000000'
                        ),
                );

                $request = $this->api->api_call_put($serviceApiUrl,'', $data_array);

I’ve left object creation line in for ref. Either using the $obj variable or the created array above doesn’t change the geo object in the service. The code above does update the port_id and I can update other variables as well.

How can I update the geo object using the service API please?

I also tried with using http_build_query and appending the params to the end of the URL as below, however that didn’t work either.

                $params = [
                        'geo' => [
                                'address' => 'example',
                        ],
                ];

                $serviceApiUrl = "admin/customers/customer/".$idCustomer."/internet-services--".$idService.'?'. http_build_query($params);
                $request = $this->api->api_call_put($serviceApiUrl, $idCustomer, $params );

Regards,
Ian

Hello! Thank you for posting your inquiry on our forum, we would kindly ask you to reach out to our support team via support@splynx.com for assistance.

Hi @badenoch-ian . Did you get a resolution for this as I’m having the exact same issue? I can update other customer/internet-services fields but the [geo][marker] and [geo][address] doesn’t change despite the put request returning success (202).

Hi, wiztech,

Here is the response I received from Splynx Support back in January 2024:

“Sorry for the inconvenience, we already know about this problem. The geo update in the services will be fixed in Splynx version 4.3.”

I worked around the problem by creating a file full of sql inserts and running it manually as follows:

foreach($internet_services as $service)
{
 $gps = $geo['geolat'].','.$geo['geolong'];
 echo "INSERT INTO service_geo (service_id, gps) VALUES (.$service['id']., .$gps.);"
}

The $gps string is just lat and long separated with a comma.

I’ve no idea if it has been fixed yet because I’ve never had to use it again though judging from your question I guess not. I’ve just checked the latest schema and it looks like the table is now called service_geo_data - but as the data is in the same format I see no reason the code won’t still work by only changing the table name.

Hi,

So Volodymyr at Splynx was super quick in responding and my PUT requests are now working.
. There’s a separate API request URL for the marker and address when using a PUT request and they no longer need contained in a [geo] parent array…

The internet-services-- part of the URL becomes geo-internet-service–

1 Like

Hi, good stuff! The API is generally a pleasure to work with and support have been a great help. Glad to hear it’s sorted.

1 Like