Support / Knowledge Base / HOW TO: Device Cloud: Add Data To A Data Stream

HOW TO: Device Cloud: Add Data To A Data Stream

In this example, we will add data to a Data Stream associated with a device ID. We will be using the following web services interface:

  • /ws/v1/streams/history

Add Multiple Data Points to a Stream

This scenario is built on top of the example to query data form a device. We will take the data returned for the <system> tag from the device in that example and insert that data to a stream containing the ID of the associated device. 

  1. We will begin with the response from the <query_setting> request in the referenced example since we will use that data for this example

    SCI response for RCI <query_setting> request
    <sci_reply version="1.0">
      <send_message>
        <device id="00000000-00000000-00409DFF-FF000000">
          <rci_reply version="1.1">
            <query_setting>
              <system>
                <contact>Me</contact>
                <location/>
                <description>My DIA Demo</description>
              </system>
            </query_setting>
          </rci_reply>
        </device>
      </send_message>
    </sci_reply>
  2. Now, take the device ID, <contact> and <description> fields and use that data to construct new content to POST to the /ws/v1/streams/history interface

    POST content for /ws/v1/streams/history request (JSON format)
    [{
      "stream_id""00000000-00000000-00409DFF-FF000000/system/contact",
      "stream_type""STRING",
      "value""Me"
    },
     {
       "stream_id""00000000-00000000-00409DFF-FF000000/system/description",
       "stream_type""STRING",
       "value""My DIA Demo"
     }]

    Note: That example uses JSON. You may also use XML syntax

    POST content for /ws/v1/streams/history request (XML format)
    <list>
      <datapoint>
        <stream_id>00000000-00000000-00409DFF-FF000000/system/contact</stream_id>
        <value>Me</value>
      </datapoint>
      <datapoint>
        <stream_id>00000000-00000000-00409DFF-FF000000/system/description</stream_id>
        <value>My DIA Demo</value>
      </datapoint>
    </list>
  3. Now you can see your new streams in the Data Services section of the UI, or access them using web services (including push monitors)
User-added image
Last updated: Aug 23, 2018

Filed Under

Digi Remote Manager

Recently Viewed Articles

No recently viewed articles
Contact a Digi expert and get started today! Contact Us