Send Using REST

Sending Entire JSON Message in HTTP Body

  • Endpoint: ${BASE_URL}/push/json/message
  • Content-Type: application/json
  • Method: POST
  • Body: JSON Message
curl --request POST \
  --url http://your_host_or_ip/api/push/json/message \
  --header 'accept: application/json' \
  --header 'content-type: application/json' \
  --data '{"header":{"key":"your_domain_key","api":"your_api_key","did":"your_device_id","dmdl":"your_device_model","fwver":"device_firmware_version","mid":1000},"data":{"latitude":32.779167,"longitude":-96.808891,"temperature":26,"humidity":77,"precipitation":0,"wind":11}}'
var request = require("request");

var options = {
  method: 'POST',
  url: 'https:///api/push/json/message',
  headers: {accept: 'application/json', 'content-type': 'application/json'},
  body: '{
  "header": {
    "key": "your_domain_key",
    "api": "your_api_key",
    "did": "your_device_id",
    "dmdl": "your_device_model",
    "fwver": "device_firmware_version",
    "mid": 1000
  },
  "data": {
    "latitude": 32.779167,
    "longitude": -96.808891,
    "temperature": 26,
    "humidity": 77,
    "precipitation": 0,
    "wind": 11
  }
}'
};

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://your_host_or_ip/api/push/json/message")
payload = {
  "header": {
    "key": "your_domain_key",
    "api": "your_api_key",
    "did": "your_device_id",
    "dmdl": "your_device_model",
    "fwver": "device_firmware_version",
    "mid": 1000
  },
  "data": {
    "latitude": 32.779167,
    "longitude": -96.808891,
    "temperature": 26,
    "humidity": 77,
    "precipitation": 0,
    "wind": 11
  }
}

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Post.new(url)
request["accept"] = 'application/json'
request["content-type"] = 'application/json'
request.body = payload.to_json

response = http.request(request)
puts response.read_body
var url = "https://your_host_or_ip/api/push/json/message";

var data = {
  "header": {
    "key": "your_domain_key",
    "api": "your_api_key",
    "did": "your_device_id",
    "dmdl": "your_device_model",
    "fwver": "device_firmware_version",
    "mid": 1000
  },
  "data": {
    "latitude": 32.779167,
    "longitude": -96.808891,
    "temperature": 26,
    "humidity": 77,
    "precipitation": 0,
    "wind": 11
  }
};

var xhr = new XMLHttpRequest();

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("POST", url);
xhr.setRequestHeader("accept", "application/json");
xhr.setRequestHeader("content-type", "application/json");

xhr.send(JSON.stringify(data));
import requests
import json

url = "https://your_host_or_ip/api/push/json/message"

headers = {
    'accept': "application/json",
    'content-type': "application/json"
}

body = {
  "header": {
    "key": "your_domain_key",
    "api": "your_api_key",
    "did": "your_device_id",
    "dmdl": "your_device_model",
    "fwver": "device_firmware_version",
    "mid": 1000
  },
  "data": {
    "latitude": 32.779167,
    "longitude": -96.808891,
    "temperature": 26,
    "humidity": 77,
    "precipitation": 0,
    "wind": 11
  }
}

payload = json.dumps(body)
response = requests.request("POST", url, data=payload, headers=headers)

print(response.text)

Sending JSON Data in HTTP Body

  • Endpoint: ${BASE_URL}/push/json/{dkey}/{akey}/{did}/{dmdl}/{fwver}/{mid}
  • Content-Type: application/json
  • Method: POST
  • Body: JSON Data
curl --request POST \
  --url https:///api/push/json/your_domain_key/your_api_key/your_device_id/your_device_model/device_fw_version/1000 \
  --header 'accept: application/json' \
  --header 'content-type: application/json' \
  --data '{"latitude":32.779167,"longitude":-96.808891,"temperature":26,"humidity":77,"precipitation":0,"wind":11}'
var request = require("request");

var options = {
  method: 'POST',
  url: 'https:///api/push/json/your_domain_key/your_api_key/your_device_id/your_device_model/device_fw_version/1000',
  headers: {accept: 'application/json', 'content-type': 'application/json'},
  body: {"header":{"key":"your_domain_key","api":"your_api_key","did":"your_device_id","dmdl":"your_device_model","fwver":"device_firmware_version","mid":1000},"data":{"latitude":32.779167,"longitude":-96.808891,"temperature":26,"humidity":77,"precipitation":0,"wind":11}}
};

request(options, function (error, response, body) {
  if (error) throw new Error(error);
  console.log(body);
});
require 'uri'
require 'net/http'
require 'openssl'

url = URI("https:///api/push/json/your_domain_key/your_api_key/your_device_id/your_device_model/device_fw_version/1000")

payload = {
  "latitude": 32.779167,
  "longitude": -96.808891,
  "temperature": 26,
  "humidity": 77,
  "precipitation": 0,
  "wind": 11
}

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Post.new(url)
request["accept"] = 'application/json'
request["content-type"] = 'application/json'
request.body = payload.to_json

response = http.request(request)
puts response.read_body
var url = "https://your_host_or_ip/api/json/{domain_key}/{api_key}/{device_id}/{device_model}/{firmware_version}/1000";

var data = {
  "latitude": 32.779167,
  "longitude": -96.808891,
  "temperature": 26,
  "humidity": 77,
  "precipitation": 0,
  "wind": 11
};

var xhr = new XMLHttpRequest();

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("POST", url);
xhr.setRequestHeader("accept", "application/json");
xhr.setRequestHeader("content-type", "application/json");

xhr.send(JSON.stringify(data));
import requests

url = "https://your_host_or_ip/api/json/{domain_key}/{api_key}/{device_id}/{device_model}/{firmware_version}/1000"

headers = {
    'accept': "application/json",
    'content-type': "application/json"
}

body = {
  "latitude": 32.779167,
  "longitude": -96.808891,
  "temperature": 26,
  "humidity": 77,
  "precipitation": 0,
  "wind": 11
}

payload = json.dumps(body)
response = requests.request("POST", url, data=payload, headers=headers)

print(response.text)

Sending Hex / Base64 encoded JSON Data in HTTP Body

  • Endpoint: ${BASE_URL}/push/raw/{dkey}/{akey}/{did}/{dmdl}/{fwver}/{mid}
  • Content-Type: text/plain
  • Method: POST
  • Body: JSON Data encoded as String or Hex or Base64
    • If encoded as Hex, the format query parameter should be HEX
    • If encoded as Base64, the format query parameter should be BASE64
curl --request POST \
  --url 'https://your_host_or_ip/api/push/raw/your_domain_key/your_api_key/device_id/device_model/fw_version/1000?format=BASE64' \
  --header 'accept: application/json' \
  --header 'content-type: text/plain' \
  --data '"ew0KICAibGF0aXR1ZGUiOiAzMi43NzkxNjcsDQogICJsb25naXR1ZGUiOiAtOTYuODA4ODkxLA0KICAidGVtcGVyYXR1cmUiOiAyNiwNCiAgImh1bWlkaXR5IjogNzcsDQogICJwcmVjaXBpdGF0aW9uIjogMCwNCiAgIndpbmQiOiAxMQ0KfQ=="'
var request = require("request");

var options = {
  method: 'POST',
  url: 'https://your_host_or_ip/api/push/raw/your_domain_key/your_api_key/device_id/device_model/fw_version/1000',
  qs: {format: 'BASE64'},
  headers: {accept: 'application/json', 'content-type': 'text/plain'},
  body: '"ew0KICAibGF0aXR1ZGUiOiAzMi43NzkxNjcsDQogICJsb25naXR1ZGUiOiAtOTYuODA4ODkxLA0KICAidGVtcGVyYXR1cmUiOiAyNiwNCiAgImh1bWlkaXR5IjogNzcsDQogICJwcmVjaXBpdGF0aW9uIjogMCwNCiAgIndpbmQiOiAxMQ0KfQ=="'
};

request(options, function (error, response, body) {
  if (error) throw new Error(error);
  console.log(body);
});
require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://your_host_or_ip/api/push/raw/your_domain_key/your_api_key/device_id/device_model/fw_version/1000?format=BASE64")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Post.new(url)
request["accept"] = 'application/json'
request["content-type"] = 'text/plain'
request.body = "\"ew0KICAibGF0aXR1ZGUiOiAzMi43NzkxNjcsDQogICJsb25naXR1ZGUiOiAtOTYuODA4ODkxLA0KICAidGVtcGVyYXR1cmUiOiAyNiwNCiAgImh1bWlkaXR5IjogNzcsDQogICJwcmVjaXBpdGF0aW9uIjogMCwNCiAgIndpbmQiOiAxMQ0KfQ==\""

response = http.request(request)
puts response.read_body
var url = "https://your_host_or_ip/api/push/raw/your_domain_key/your_api_key/device_id/device_model/fw_version/1000?format=BASE64";

var data = "\"ew0KICAibGF0aXR1ZGUiOiAzMi43NzkxNjcsDQogICJsb25naXR1ZGUiOiAtOTYuODA4ODkxLA0KICAidGVtcGVyYXR1cmUiOiAyNiwNCiAgImh1bWlkaXR5IjogNzcsDQogICJwcmVjaXBpdGF0aW9uIjogMCwNCiAgIndpbmQiOiAxMQ0KfQ==\"";

var xhr = new XMLHttpRequest();

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("POST", url);
xhr.setRequestHeader("accept", "application/json");
xhr.setRequestHeader("content-type", "text/plain");

xhr.send(data);
import requests

url = "https://your_host_or_ip/api/push/raw/your_domain_key/your_api_key/device_id/device_model/fw_version/1000"

querystring = {"format":"BASE64"}

payload = "\"ew0KICAibGF0aXR1ZGUiOiAzMi43NzkxNjcsDQogICJsb25naXR1ZGUiOiAtOTYuODA4ODkxLA0KICAidGVtcGVyYXR1cmUiOiAyNiwNCiAgImh1bWlkaXR5IjogNzcsDQogICJwcmVjaXBpdGF0aW9uIjogMCwNCiAgIndpbmQiOiAxMQ0KfQ==\""

headers = {
    'accept': "application/json",
    'content-type': "text/plain"
    }

response = requests.request("POST", url, data=payload, headers=headers, params=querystring)

print(response.text)

Worth Seeing