HTTP
NUBISON IoT's standard HTTP protocol.
This is a guide for connecting a device that sends data to the Nubison IoT platform via HTTP.
Before proceeding with the steps below, Getting Startedthe procedures listed must be completed beforehand.
Basic
Please refer to the Getting Started section for the following communication platform information.
Device key: “{product code}_{device Identifier}"
Product Code
Client ID
Client Secret
Server Connection
Information for connecting to the Nubison IoT platform via HTTP.
Server URL: Provided during integration
Device Login
Log the device into the Nubison IoT platform.
You must perform login before making other requests.
You can send other requests using the access token returned in the login response.
Also, "Cloud connection" will be recorded in the timeline on the Nubison IoT platform web.
POST /devices/login
[Request]
Content-Type: application/x-www-form-urlencoded
<Header>
Authorization
O
Basic <${
Client ID}:${
Client Secret}
string encoded in base64>
ex.
Client ID = AbCdE123
, Client Secret = xyzabc123
then,
Basic AbCdE123:xyzabc123
Here, Base64 encode AbCdE123:xyzabc123
(Basic QmFzaWMgQWJDZEUxMjM6eHl6YWJjMTIz
) must be sent.
<Body>
deviceKey
O
Device key
[Response] Content-Type: application/json
status
message
body
200
OK
{
"AccessToken" : "...."
}
400
Bad Request
{
"code" :"ERROR401",
"message": "authorization header does not exist."
}
{
"code" :"ERROR402",
"message": "deviceKey is missing."
}
{
"code" :"ERROR403",
"message": "client is not valid."
}
405
Not Found
// When the service does not exist
415
Invalid content-type
// content-type must be application/json
Device Logout
The device logs out from the NUBISON IoT platform.
The used token will be revoked, and "cloud disconnection" will be recorded in the timeline on the Nubison IoT platform web.
POST /devices/logout
[Request]
Content-Type: application/json
<Body>
accessToken
O
The access token received from the server when logging into the NUBISON IoT platform
deviceKey
O
Device key
Example
{
"accessToken": "FDFC4115B4275502fc6a6111",
"deviceKey": "IQY9TFMH_HTTPABC"
}
[Response] Content-Type: application/json
status
message
body
200
OK
// Deletes the access token issued at server login.
400
Bad Request
{
"code" :"ERROR402",
"message": "deviceKey is missing."
}
{
"code" :"ERROR404",
"message": "accessToken is missing."
}
401
Unauthorized
// accessToken is not valid.
405
Not Found
service is not found. or device is not registered.
415
Invalid content-type
// content-type must be application/json
Data Transmission
Send device data to the Nubison IoT platform.
POST /devices/data
[Request] Content-Type: application/json
<Body>
accessToken
O
The access token received from the server at login
deviceKey
O
Device key
data
O
Device data
[Response] Content-Type: application/json
status
message
body
201
Created
400
Bad Request
{
"code" :"ERROR402",
"message": "deviceKey is missing."
}
{
"code" :"ERROR404",
"message": "accessToken is missing."
}
{
"code" :"ERROR406",
"message": "data is missing."
}
401
Unauthorized
// accessToken is not valid.
415
Invalid content-type
// content-type must be application/json
When using automatic driver Default payload specification
When using an automatically generated driver on the Nubison IoT platform, send the Body data
value as follows so that the data sent by the device can be stored on the Nubison IoT platform.
{
...
"data": {
"unit number": unit value
}
}
If you use the auto driver, structure the data as follows.
In the request body JSON, under the "data" key, construct a JSON object where the unit number is used as the key and the unit value as the value, and send the data in this format. (When using an auto-generated driver, the Nubison IoT platform server will distinguish the data based on the unit number sent by the device and store the unit value under the corresponding unit number.)
Numeric and location data in numeric format,
text data in text format,
numeric array data in numeric array format,
text array data in text array format,
Images as base64-encoded strings
Unit 0: Temperature (number)
Unit 1: Humidity (number)
Unit 2: Mode (text)
Unit 3: Latitude (location)
Unit 4: Longitude (location)
Unit 5: Temperature data array (number array)
Unit 6: Mode data array (text array)
Unit 7: Captured image (image)
If the data is sent as follows
Unit 0 "Temperature" data value: 32
Unit 1 "Humidity" data value: 46
Unit 2 "Mode" data value: "default"
Unit 3 "Latitude" data value: 38.23
Unit 4 "Longitude" data value: 128.34
Unit 5 "Temperature data array" data value: [27,28,24,23,25]
Unit 6 "Mode data array" data value: ["default", "sleep", "mood"]
Unit 7 "Image" data value: /9j/4AAQSkZJRgABAQAAAQABAAD/2w...
Construct the payload as follows.
{
"deviceKey": "AZ29TVMH_HTTPSAMPLE123", // The device key of the device sending the data
"accessToken": "CDAC4215B4271202fc6a6111", // The access token received via POST /devices/login
"data": {
"0": 32,
"1": 84,
"2": "default",
"3": 38.23,
"4": 128.34,
"5": [27,28,24,23,25],
"6": ["default", "sleep", "mood"],
"7": "/9j/4AAQSkZJRgABAQAAAQABAAD/2w..."
}
}
Last updated