Metadata

This endpoint is used to send device metadata to the Konnectware platform to onboard the device. Usually, metadata is registered through Konnectware's administration user interface. But, this API also facilitates programmatic update of the device's metadata if required.

POST https://api-dev.konnectware.com/api/device/metadata

Headers

Name
Type
Description

Authorization*

String

bearer token

Content-Type*

String

application/json

Request Body

Name
Type
Description

message*

String

metadata from each device

{
    // Response
}

Here is the sample message format used as JSON body while making a POST call

{

"message":"{"ID":"Device 1","Loc":"Columbus"}"

}

The API is authenticated with the token you acquired from the settings section of the Konnectware admin user interface.

#include "WiFi.h"
#include "HTTPClient.h"
#include "DHTesp.h"

#define DHTpin 15
DHTesp dht;
WiFiClient client;
HTTPClient http;

const char* ssid = "<YOUR-WIFI-USERNAME>"; 
const char* password =  "<YOUR-WIFI-PASSWORD>"; 
const char* serverName = "https://api-dev.konnectware.com";
const char* metadataendpoint = "/api/device/metadata"; 

int main(int argc, char *argb[]) 
{
  Serial.begin(115200);
  
  // Establish wifi connection
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.println("Connecting to WiFi..");
  }
 
  Serial.println("Connected to the WiFi network");
  dht.setup(DHTpin, DHTesp::DHT22);
  
  /* Composing and sending device metadata.
   */
  
  String metadata = "{\\\"ID\\\":\\\"Device 1\\\",\\\"Loc\\\":\\\"Columbus\\\"}";
  http.begin(client, serverName+metadataendpoint);
  http.addHeader("Content-Type", "application/json");
  http.addHeader("Authorization", "<YOUR-BEARER-TOKEN>");
  String httpRequestData = "{\"message\":\""+message+"\"}";
  int httpResponseCode = http.POST(httpRequestData);
  Serial.println(httpResponseCode);
  http.end();
}

Last updated