Skip to Content

Internet of Things (IoT) Adding a new device to the IoT Services


Internet of Things (IoT) Adding a new device to the IoT Services

By Craig Cmehil

Part 7 of 10, Add a new device to your IoT Services

You will learn

With the MMS service now deployed, and your user assigned the appropriate role it’s time for to add your device(s) so you can communicate with it. To do this you will add your device to the service.


  1. From the HCP cockpit, select Java Applications then select the iotmms application. Open the Message Management Service Cockpit by clicking on the Application URL.

    Application URL

  2. Click on the View registered devices and device types tile to open the IoT Services Cockpit. You will use this page frequently, so it is worth bookmarking it.

    View registered devices

  3. Click the Message Types tile, then the + symbol to add a new message type and define the structure of the data you will to collect. In the Information section, enter a name (climateData)

    Device definition

  4. In the Fields section, click the + Add Field button to add in two more fields, then enter the following for name and data types. Click the Create button (bottom right corner) when complete. When the message type is created, copy the ID string. You will need it later.

    Note: Be sure to follow the names and capitalization specified below.

    Name Type
    timestamp long
    Humidity double
    Temperature double

    Make sure timestamp in your definition has data type long, and not default date.

    The message type ID:

    ID value

  5. Click the “back arrow” again to return the the IoT Services Cockpit. Click on Device Types, then the + symbol to create a new device. Give it a simple name that makes sense for what you are doing (e.g. TesselClimate). Now click the + symbol to attach your previously created Message Type and click Create.

    New Device Type

  6. Finally you can now click the “back arrow” and create the final item, your Device.

    This is extremely important, once you click Create a pop-up will appear that will display the OAuth access token for this new device. Copy that and save it somewhere, you will need it soon. If you lose it, click into the Authorization tab and you can generate a new token.


  7. When the OAuth Access Token is displayed, copy the token ID and save it. Click Close.


  8. Copy and save the Device ID string

    Device ID

  9. With the device type, message type and device configured, it is time to send some data.
    Go to the IoT Services Cockpit and click the View messages received, use sample clients, etc. tile. Then click the Send and receive messages through HTTP tile.

    View Messages

    View stored messages

  10. On the HTTP API page, you will see a Sample Client to Send Messages with an HTTP endpoint like this:

  1. You will next formulate your HTTP POST payload. Since you are sending OData, numbers (float, int, double, etc) are not placed in double quotes, while strings and the Key of the Key/Value pair are in quotes.

    Under Message to post replace the existing content with the following which matches the message type your used earlier.

    {"mode":"sync", "messageType":"6c7a02f24cc32ee07174", "messages":[{"Humidity":25.7, "Temperature": 76.5, "timestamp":1431450313}]}

    NOTE - the messageType value needs to be changed to match your message type ID.

  2. Click the POST button. If everything goes OK, you should see a response code of 200 similar to this screen shot.

    Server Reply

    You may receive as well with response code 202 which indicates your request was not immediately processed but is placed in a processing queue. You should copy returned HTTP endpoint into Receive acknowledgments field to receive the status of your queued message.

    Response codes 4xx or 5xx indicate that post request has failed.

  3. To verify that the posting worked, switch back IoT Services Cockpit, click View messages received, use sample clients, etc. tile, then click the Display stored messages tile. When the page updates you should see something like this:

    Viewing stored messages

  4. Now you will post from an external REST client. In this step you will use Postman Extension for Google Chrome.

    Once installed in Chrome open the Postman extension in incognito mode to avoid authentication issues in the same browser session with SAP HCP. For that you might need to allow the Postman extension to run in Chrome’s incognito mode.

    Postman extension in incognito mode

  5. Copy the HTTP endpoint to it and select “POST” from the drop down menu.

    Open the “Headers” section and change the “Authorization” value to “Bearer [TOKEN ID]” using the Token you copied when you added our device to the system.

    Authorization values

  6. Select then the “RAW” type and copy and paste in the same content you just had (with a few value changes to make it easier to spot this insert. Make sure you change the messageType to your ID.

    {"mode":"sync", "messageType":"6c7a02f24cc32ee07174", "messages":[{"Humidity":35.7, "Temperature": 86.5, "timestamp":1431450313}]}

  7. Click Send and you should receive a message similar to when you used the HCP tool. This indicates that your POST was successful and if you return to the “Display Stored Messages” you will see your new entry.

    If you receive 40x authorization error in return, then check if you are running Postman client in Chrome’s incognito mode.

Next Steps

Back to top