Manage device attributes via the Device Inventory REST API
Device attributes are not supposed to change very often. By default, you should have read and write permissions on device attributes.
Goal
To add additional attributes to your device or change the value of an existing attribute.
Example - you can use such attributes to filter devices, for example by their manufacturer attribute.
Procedure
Authorize
Click
in the top right area of the screen or the similar icon to the right of the respective method in order to get a pop-up offering basic authentication.
Authenticate with a Suite Auth token (the same as you created during Provisioning via Device Provisioning API).
Close the pop-up.
Get all attributes of the hello world device
Navigate to GET /di/devices/{deviceId}/attributes
Click Try it out to get access to the input fields.
deviceId: set the full name of your device, e.g. your-namespace:hello-world-device-01
Execute.
The response would be for example:
[
{
"path"
:
"Info"
,
"value"
: {
"displayName"
:
""
,
"gateway"
:
false
}
}
]
Add the manufacturer attributes
Navigate to PUT /di/devices/{deviceId}/attributes
Click Try it out to get access to the input fields.
deviceId: set the full name of your device, e.g. your-namespace:hello-world-device-01
Set the Request body.
It must be of type application/json.
It must respect the thing's notation.
In our case the request body looks like this:{
"path"
:
"manufacturer"
,
"value"
: {
"name"
:
"ACME demo corp."
,
"location"
:
"London"
,
"serialno"
:
"420"
,
"model"
:
"fancy"
}
}
Execute
The response code 200 indicates success.
can't parse JSON. Raw result:
The Attribute of the specific Device was successfully added.
You can re-execute the GET request to see the change.
Check your work
The changes triggered via the Bosch IoT Manager API are forwarded to Bosch IoT Things.
You can see the latest values in the Bosch IoT Consoles, for example you can refresh the thing attributes view in the Developer Console to see the results.
Tips for debugging
Please check if the change has be applied.
Developer Console - in case all attributes are missing - the mapping failed just because the path you have mentioned in the request body does not exist.
Follow the steps at Manage attributes via Bosch IoT Suite UI, then re-try the POST request.Things UI - navigate to Connections/Integrations > Device Management > Metrics > click one of the numbers in a 'failure' cell.
Activate the log entries and Refresh automatically.
Re-try the PUT request and see the detailed failure message.