Skip to main content

HTTP Server

Requirements

  • Android application with version 3.0.88 or higher.
  • Windows application with version 3.1.301 or higher.
  • JSCore application with version 4.1.396 or higher.

Setup

In order to utilize the HTTP server, it is necessary to apply a configuration to your device.
You have to configure the settings through the right-click menu on the device:

Device Properties >> Set >> Set sensor configuration

No-auth

You simply need to make a GET or POST request to the targeted device's IP address.

{
"services": [
{
"uid": "test",
"type": "HTTP",
"settings": {
"port": 8181
}
}
]
}

Basic-auth

In this configuration type, there's a basic authentication step involved.
You'll need to include a username ( YOUR_USERNAME ) and password ( YOUR_PASSWORD ) in your GET or POST request.

NOTE

Ensure that the authentication credentials are matching the one configured on the target device.

{
"services": [
{
"uid": "test",
"type": "HTTP",
"settings": {
"authCredentials": {
"username": "YOUR_USERNAME",
"password": "YOUR_PASSWORD"
},
"port": 8181
}
}
]
}

How it works

The server is running with HTTP on the 8181 port and receives POST or GET requests on the /api/sensor/event endpoint, and if the authCredentials property is set in the configuration then uses basic-auth for security

GET - method

A GET request can be sent to the receiver device to this endpoint in this format:

http://<device ip>:8181/api/sensor/event?event=anyEvent&id=anyId&value=anyValue

POST - method

A POST request can be sent to receiver device to this endpoint

http://<device ip>:8181/api/sensor/event

In this method a request body has to be sent to endpoint that has to be a JSON that matches this format:

{
"id":"sensorId",
"event":"anyEvent",
"value": "anyValue"
}

Authentication

info

If the authCredentials property is set in the configuration then the incoming request has to have a valid Authorization header with the same username and password in basic-auth format.

Server response list

200: Everything is OK the server handled the response.
400: The received body’s format is not valid.
401: Bad Authorization data.
500: Internal server error.


Legacy - HTTP server

Please note:

These configurations are incompatible with all versions of JsCore applications.

Requirement

  • Android application with version 3.0.88 or higher.
  • Windows application with version 3.1.301 or higher.

Setup

With authCredential

{
"embeddedServices": [
{
"id": "http-server",
"type": "httpServer",
"settings": {
"authCredentials": {
"name": "username",
"password": "password"
}
}
}
]
}

The authCredentials property is optional, if you do not wish to use authentication for the server, then you do not have to set this property.

Without authCredentials

{
"embeddedServices": [
{
"id": "http-server",
"type": "httpServer",
"settings": {}
}
]
}

The method of utilization is identical to the steps listed above.

Downloadable content