Publish Data

The following HTTP request method is used to allow devices, applications, and services to publish data in the CloudPlugs IoT platform to communicate with other Production Things and Controllers. Data published may be a boolean, a number, a JSON Object or a JSON Array.

It is a best practice to organize your Channels to allow the easy retrieval of published data using the power and flexibility of wildcards (# / +). With a single HTTP request, you can Publish data in the following ways:

  • Publish a single data object from a single source (for example, the current value from a single sensor on a device).
  • Publish a single data object from multiple sources (for example, the current value from multiple sensors on one or more devices).
  • Publish multiple data objects in an Array from a single source (for example, buffered historical values from a single sensor on a device).
  • Publish multiple data objects in an Array from multiple sources (for example, multiple sets of buffered historical values, each from a different sensor on one or more devices).

Notes:

  • at allows to override the current timestamp of the published data and to set it to a different time and date.
  • of is an optional parameter that sets the Plug_ID of the Thing that will publish the data.

Request

Method :

PUT

Base Url :

http://api.cloudplugs.com/iot/data/CHANNEL

Headers :

X-Plug-Id  : [PLUG_ID] // The PlugId received on the response of a successful enrollment
X-Plug-Auth   : [String] //  Auth string or Authentication Connection password received on the response of a successful enrollment

Body :

 [{
   "id"        : [OID],   // optional, of a data record ( You can use it to modify the old published )
   "channel"   : [CHANNEL],  // optional, to override in the url
   "data"      : [JSON],
   "at"        : [TIMESTAMP], // optional, to override the timestamp ( ms ) of published data
   "of"        : [PLUG_ID], // optional, Plug-ID the Thing that will publish this data record.
   "expire_at" : [TIMESTAMP],  // optional, expiration date of this data entry (data retention period)
   "ttl"       : [Number]    // optional, how many *seconds* this data entry will live (if "expire_at" is present, then field ignored implemented)
 },...]

Response

Status :

200 OK  // in case of success

Body :

 "OID" || ["OID", ... ] 		// the ID string or an array of ID strings
Still need help? Get in touch!
Last updated on 6th May 2021