REST API - Update lat/long question

Hi, under section 9.3 of the cnMaestro RESTFUL API guide titled Update Device Configuration, the body parameters list latitude, longitude, and description. Would this be usable to update SMs for these fields or is this request only meant for APs?

Thanks!

1 Like

Hi rnelson,

Yes, those fields are also applicable for SMs. Depending on the product line, values set against the device in cnMaestro also get applied to the physical device as well.

Oh that is what we are looking for - setting it directly on the SM. We use 450b. Is that a product line that can directly set it on the SM via the REST API?

Yes, latitude and longitude updates made in cnMaestro will set changes on the device for PMP and ePMP for both APs and SMs.

The description field will not be sent to the device. That is a cnMaestro-only parameter.

If there are any other configuration settings that you want applied directly on devices, this can be accomplished via templates and replacement variables.

  1. Create a configuration template using the UI
  2. In the devices API send the template name in the “template” field and replacement variable values in the “variables” object.

Example template named “my_template”:

{
    "some_parameter": "${UNIQUE=default value}"
}

PUT device payload:

{
    "template": "my_template",
    "variables": 
        {
             "UNIQUE": "new value"
        }
}

The API call will result in the below configuration template being sent to the device:

{
    "some_parameter": "new value"
}

That value of variables.UNIQUE is saved against the device like in the UI for future use. To unset the value send variables.UNIQUE as null.

Oh that is excellent! Is there a document that contains which json key fields are replaceable?

Yes, there is the API documentation on the support site, Swagger documentation that you can see locally by clicking the Try It Out link on your API client page or here to get quick access.

The Swagger documentation linked from your On-Premises installation is preferred because it will allow testing APIs with example payloads you set up.

In terms of JSON templates, it depends on the product line. If there is documentation available it will on the support site for that specific device product line.

Typically people create their own templates by applying desired settings on a test device and then exporting that device’s configuration. This can be done via the device web UI or in cnMaestro with the View Device Configuration link in the Configuration tab of the dashboard. The exported JSON can be placed in a JSON editor/validator online for convenience. I recommend doing this so you can validate that the JSON file format is preserved. Then remove all settings except the ones you want included in your template.

With replacement variables you can make any section of the template unique per-device. The variables will be replaced with the device-specific or default values before being sent to the device. Templates also support macros now to automatically insert the device’s serial number or MAC address.

  • ${VARIABLE_NAME=optional default value} will be replaced with a device-specific value or the default value if one is not available
  • ${VARIABLE_NAME} will not send configuration unless a device-specific value is set
  • %{ESN} will be replaced with the device’s MAC address
  • %{MSN} will be replaced with the device’s Serial Number

Note: if you use replacement variables for things like numbers or Booleans, then your JSON validator might mark that as invalid. However, cnMaetro will allow this and will insert replacement variable values before sending the file to the device. You must ensure that replacement variables are set up to allow the final JSON to be valid.

Example Boolean parameter:

{
   "option_enabled": ${OPTION=true}
}

Will send

{
   "option_enabled": true
}

Be careful because surrounding the variable in quotes will result in a string being sent instead of a Boolean.

{
   "option_enabled": "${OPTION=true}"
}

Will send

{
   "option_enabled": "true"
}
1 Like

Thank you - I will give this a try !

1 Like