Bosch IoT Device Management - will be discontinued by mid 2024

Manage attributes via Things HTTP API

In general, the digital twin layer regards attributes as something that does not change very often.
However, think about the case that a device has been moved to another location and you want the attributes to be up to date.

Goal

Let us assume, your hello world thing already has manufacturer attributes that need to be updated.

In this example you move the device to London and also update new serial number.

Procedure

Navigate to Bosch IoT Things - HTTP API docs.

Authorize

In order to use the Things HTTP API, you will need to authenticate. In this example we authenticate with a bearer token, using the client created in Provisioning via Device Provisioning API.

Navigate to your OAuth2 clients UI feature or open https://console.bosch-iot-suite.com/oauth2-clients/, select the client you want to use, click the client actions button and then click Use access token. From the Use access token blade that comes from the right, copy the value that suits your needs to your clipboard.
images/confluence/download/attachments/1634788013/dm_tutorials_oauth2_useToken.png


Then enter it in the Authorization field.

images/confluence/download/attachments/1634788013/things-auth.png

Close the pop-up.

List all attributes of a specific thing

This request simulates how your business application might request for the attributes of this device.

  • Navigate to Things > GET /things/{thingId}/attributes.

  • Click Try it out. to get access to the entry fields.

  • Set the thingId - in our example it is example.dm:hello-world-device-01

  • The other fields are optional and will stay empty for now.

  • Click Execute.

Response example is

{
"Info": {
"displayName": "",
"gateway": false
},
"manufacturer": {
"name": "ACME demo corp.",
"location": "Berlin",
"serialno": "42",
"model": "fancy"
}
}

The Info attribute will only appear because the the Bosch IoT Suite Console set it at the time of provisioning.

Create or update a specific attribute of a specific thing

This request simulates how your business application might change the attributes of the device.

  • Navigate to Things > PUT /things/{thingId}/attributes/{attributePath}.

  • Click Try it out. to get access to the entry fields.

  • Set the thingId - in our example it is example.dm:hello-world-device-01.

  • Set the attributePath- in our example manufacturer/serialno.

  • Set the Request body to 4200.

  • Click Execute.

Result

The response example is 204, meaning the attributes were successfully modified.

Check your work

You can either use the Bosch IoT Suite Console to see if the attribute is changed, or you can request again all attributes using the HTTP API.

GET /things​/{thingId}​/attributes


A second GET request would respond like in the following snippet:

{
"manufacturer": {
"name": "ACME demo corp.",
"location": "London",
"serialno": "4200",
"model": "fancy"
}
}