# NBI script behaves differently

**URL:** <https://forum.genieacs.com/t/nbi-script-behaves-differently/7230>\
**Category:** Help\
**Created:** [November 8, 2025, 7:00pm UTC](https://forum.genieacs.com/t/nbi-script-behaves-differently/7230 "2025-11-08T19:00:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tarikt](https://avatars.discourse-cdn.com/v4/letter/t/4da419/32.png) [@tarikt](https://forum.genieacs.com/u/tarikt)\
**Post date:** [November 8, 2025, 7:00pm UTC](https://forum.genieacs.com/t/nbi-script-behaves-differently/7230/1 "2025-11-08T19:00:10Z")

</div>

Hi,

I have this NBI php script that behaves strangely:

```auto
<?php

require 'vendor/autoload.php';
use GuzzleHttp\Client;

$IMEI = $argv[1];
set_time_limit(180);

$client = new Client([
    'timeout' => 5.0,
]);

$response = $client->request('GET', 'http://10.100.4.38:7557/devices/', [
    'query' => [
                'query' =>'{"InternetGatewayDevice.WANDevice.1.X_NOTION_WANNetConfigInfo.IMEI":"' . $IMEI . '"}', 
                'projection' => '_deviceID._id'
                ]
]);

$body = $response->getBody();
//var_dump(json_decode($body));
$arr = json_decode($body,true);
//print_r ($arr);
if (!$arr) {
        echo "DNF \n";
        exit;
}

$id = "";
foreach ($arr as $dev){
        if (isset($dev["_id"])) {$id = $dev["_id"];}
}
//$file = "/var/log/genieacs/output.txt";
//file_put_contents($file, $id);
$response1 = $client->request('POST', 'http://10.100.4.38:7557/devices/' .$id. '/tasks?connection_request', [
    'body' => '{ "name": "setParameterValues", "parameterValues": [["InternetGatewayDevice.DownloadDiagnostics.DownloadURL", "http://speedtest.bhtelecom.ba/100MB.bin", "xsd:string"], ["InternetGatewayDevice.DownloadDiagnostics.Interface", "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1", "xsd:string"],["InternetGatewayDevice.DownloadDiagnostics.DiagnosticsState", "Requested", "xsd:string"]] }'
]); 
echo('ID is: '.$id);

$response2 = $client->request('POST', 'http://10.100.4.38:7557/devices/' . $id. '/tasks?connection_request', [
		'body' => '{"name": "getParameterValues", "parameterNames": ["InternetGatewayDevice.DownloadDiagnostics.DiagnosticsState"]}'
	]); 

?>

```

Sometimes it runs both SPV and GPV methods, sometimes just SPV and sometimes just GPV.

What could be the reason for such a strange behavior?

Best regards,

Tarik

---

<div class="post-metadata">

**Author:** ![tarikt](https://avatars.discourse-cdn.com/v4/letter/t/4da419/32.png) [@tarikt](https://forum.genieacs.com/u/tarikt)\
**Post date:** [November 20, 2025, 12:12pm UTC](https://forum.genieacs.com/t/nbi-script-behaves-differently/7230/2 "2025-11-20T12:12:49Z")

</div>

I found the reason for this issue. It was related to the fact that I actually sent 2 NBI requests in one POST method (i.e. I sent in one code line Connection request and SPV method together ). When I separated these two into two POST requests each, the issue hasn’t appeared any more.

---

<div class="post-metadata">

**Author:** ![tarikt](https://avatars.discourse-cdn.com/v4/letter/t/4da419/32.png) [@tarikt](https://forum.genieacs.com/u/tarikt)\
**Post date:** [November 26, 2025, 11:12am UTC](https://forum.genieacs.com/t/nbi-script-behaves-differently/7230/3 "2025-11-26T11:12:44Z")

</div>

This helped but it didn’t resolve the issue in all occasions. It seems that sometimes when the device is already configured with the target value, or the parameter was recently refreshed and the cached value matches the requested value GenieACS determines the task is redundant  
and silently drops it before sending it to the CPE. For that reason I added another SetParameterValues action with some dummy value on the targeted parameter before the correct value is entered via SetParameterValues. This way the success rate is 100%

---

<div class="post-metadata">

**Author:** ![westnet-paul](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/westnet-paul/32/2239_2.png) [@westnet-paul](https://forum.genieacs.com/u/westnet-paul)\
**Post date:** [November 27, 2025, 12:31pm UTC](https://forum.genieacs.com/t/nbi-script-behaves-differently/7230/4 "2025-11-27T12:31:46Z")

</div>

That seems like logical behaviour from GenieACS. If the value is already what you want it to be, why set it?
