Best Practices from Oracle Development's A‑Team

How Send a message to Oracle IoT Cloud Service

Derek Kam
Consulting Solutions Architect

In this blog, I will show you how to send a message to an IoT server from a device using the REST API. The message will be in JSON payload. 

To send a message to an Oracle IoT platform, you need a message token. This document describes how to generate a message token: https://docs.oracle.com/en/cloud/paas/iot-cloud/iotrq/op-iot-api-v2-oauth2-token-post.html. Please take note that the scope has to be an empty scope for the message toke. Below is an example of the message access token payload:


The access token will be used as the authorization token to send the message to the Oracle IoT platform.  You also require the device id, the id can be obtained from the IoT Platform->Devices->Management, and the device must be activated.

If you have a device model setup in your Oracle IoT platform with system attributes, for example:

You can send a message to the Oracle IoT platform using the model URN (e.g. urn:com:oracle:iot:cw:gps) + “:attributes” as the format, and the data will be the name of the attributes, see highlighted below:

    "eventTime": 1603753354,
    "destination": "",
    "source": "D2599C78-E2AD-4A8F-BE2C-AE274C4E68F0",
    "sender": "D2599C78-E2AD-4A8F-BE2C-AE274C4E68F0",
    "clientId": "0A5E5178-9FCF-4DC7-815A-46E86B473CA51",
    "payload": {
        "format": "urn:com:oracle:iot:cw:gps:attributes",
        "data": {
            "ora_uncertainty": 0,
            "ora_latitude": -33.717035699999997,
            "ora_altitude": 0,
            "ora_longitude": 151.0443836
    "properties": {},
    "type": "DATA",
    "priority": "LOW",
    "reliability": "BEST_EFFORT"

If you have custom data or alerts defined, then the format should be the URN of the custom data or alert. The data will be the field  you defined for this custom data, for example: 



Now you are ready to send the message using the IoT REST API ( https://{{IoT-host}}/iot/api/v2/messages) with the above payload, message access token, and the X-EndpointId in the header. (note: X-EndpointId = Device ID) using HTTP POST method.

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha