addObject and setParameterValue in same API request

Hi,

I need to create an object and then set parameters of the new created object in only one API request. An example:

{
“name”: “addObject”,
“objectName”: “InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANIPConnection”
}

{
“name”: “setParameterValues”,
"parameterValues:[[“InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANIPConnection.1.AddressingType”, “DHCP”, “xsd:string”]]
}

If the addObject can be replaced with a setParameterValue it would be awesome. Either way if this can be done in a single request in any way i would like to know it.

Im open to suggestions.

This will do what you are wanting. Put all the parameter values you want to set in the items param.

const basePath = 'InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANIPConnection';

declare(basePath + '.[]', null, {path: 0});
const items = {
    'AddressingType': 'DHCP',
};
for (let item of items) {
    const path = basePath + '.[' + Object.keys(item).map(key => key + ':' + item[key]).join(',') + ']';

    declare(path, {path: 1}, {path: 1});
}

It’s possible to do it by nbi?

Yes, but its a lot more work.

Thanks for the answer,

It does help but is a requirment in my job that the values are set through the API calls only. Can it be done in one only request in that way

This is not possible. Instance IDs are not guaranteed to be consecutive, nor to start with 1 (or restart with 1).

Ok, thanks for the help!