HTTP
Nubison IoT HTTP ํ์ค ๊ท๊ฒฉ์ ๋๋ค.
Last updated
Was this helpful?
Nubison IoT HTTP ํ์ค ๊ท๊ฒฉ์ ๋๋ค.
Last updated
Was this helpful?
Nubison IoT ํ๋ซํผ์ HTTP๋ฅผ ํตํด ๋ฐ์ดํฐ๋ฅผ ์ ์กํ๋ ๋๋ฐ์ด์ค๋ฅผ ์ฐ๊ฒฐํ๊ธฐ ์ํ ๊ฐ์ด๋์ ๋๋ค.
์๋ ๊ณผ์ ์ ์งํํ๊ธฐ ์ ์, ์ ์ ํ ๊ณผ์ ๋ค์ด ๋ฐ๋์ ์ ํ๋์ด์ผ ํฉ๋๋ค.
Nubison IoT ํ๋ซํผ์ HTTP๋ก ์ฐ๊ฒฐํ๊ธฐ ์ํ ์ ๋ณด์ ๋๋ค.
์๋ฒ URL: ์ฐ๋ ์งํ์ ์๋ด
Nubison IoT ํ๋ซํผ์ ๋๋ฐ์ด์ค๋ฅผ ๋ก๊ทธ์ธํฉ๋๋ค.
๋ค๋ฅธ ์์ฒญ์ ์งํํ๊ธฐ ์ ์ ๋ก๊ทธ์ธ์ ๋ฐ๋์ ์งํํด์ผ ํฉ๋๋ค.
๋ก๊ทธ์ธ ์์ฒญ ์๋ต์ผ๋ก ๋์์ค๋ ์ก์ธ์ค ํ ํฐ์ ์ด์ฉํ์ฌ ๋ค๋ฅธ ์์ฒญ๋ค์ ๋ณด๋ผ ์ ์์ต๋๋ค.
๋ํ Nubison IoT ํ๋ซํผ ์น์์ ํ์๋ผ์ธ์ โํด๋ผ์ฐ๋ ์ ์โ์ด ๊ธฐ๋ก๋ฉ๋๋ค.
POST /devices/login
Content-Type: application/x-www-form-urlencoded
<Header>
Authorization
O
Basic <${
ํด๋ผ์ด์ธํธ ID}:${
ํด๋ผ์ด์ธํธ Secret}
์ base64 ์ธ์ฝ๋ฉํ ์คํธ๋ง>
ex.
ํด๋ผ์ด์ธํธ ID = AbCdE123
, ํด๋ผ์ด์ธํธ Secret = xyzabc123
์ด๋ผ๊ณ ํ๋ฉด,
Basic AbCdE123:xyzabc123
์ฌ๊ธฐ์์ AbCdE123:xyzabc123๋ฅผ Base64 ์ธ์ฝ๋ฉ
(Basic QmFzaWMgQWJDZEUxMjM6eHl6YWJjMTIz
)์ ๋ณด๋ด์ฃผ์
์ผ ํฉ๋๋ค.
<Body>
deviceKey
O
๋๋ฐ์ด์ค ํค
[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
// ์๋น์ค๊ฐ ์กด์ฌํ์ง ์๋ ๊ฒฝ์ฐ
415
Invalid content-type
// content-type must be application/json
NUBISON IoT ํ๋ซํผ์์ ๋๋ฐ์ด์ค๊ฐ ๋ก๊ทธ์์ํฉ๋๋ค.
์ฌ์ฉํ๋ ํ ํฐ์ด ๋ง์๋๋ฉฐ, Nubison IoT ํ๋ซํผ ์น์์ ํ์๋ผ์ธ์ ํด๋ผ์ฐ๋ ์ ์ํด์ ๊ฐ ๊ธฐ๋ก๋ฉ๋๋ค.
POST /devices/logout
Content-Type: application/json
<Body>
accessToken
O
NUBISON IoT ํ๋ซํผ ๋ก๊ทธ์ธ ์ ์๋ฒ๋ก๋ถํฐ ๋ฐ์ ์ ๊ทผ ํ ํฐ
deviceKey
O
๋๋ฐ์ด์ค ํค
์์
[Response] Content-Type: application/json
status
message
body
200
OK
// ์๋ฒ์์ ๋ก๊ทธ์ธ ์ ๋ฐ๊ธํ access token์ ์ญ์ ํฉ๋๋ค.
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
Nubison IoT ํ๋ซํผ์ ๋๋ฐ์ด์ค ๋ฐ์ดํฐ๋ฅผ ์ ์กํฉ๋๋ค.
POST /devices/data
[Request] Content-Type: application/json
<Body>
accessToken
O
๋ก๊ทธ์ธ ์ ์๋ฒ๋ก๋ถํฐ ๋ฐ์ ์ ๊ทผ ํ ํฐ
deviceKey
O
๋๋ฐ์ด์ค ํค
data
O
๋๋ฐ์ด์ค ๋ฐ์ดํฐ
[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
Nubison IoT ํ๋ซํผ์์ ์๋ ์์ฑ๋ ๋๋ผ์ด๋ฒ๋ฅผ ์ด์ฉํ๋ ๊ฒฝ์ฐ Body์ data
๊ฐ์ ๋ค์๊ณผ ๊ฐ์ด ๋ณด๋ด์ฃผ์๋ฉด ๋๋ฐ์ด์ค๊ฐ ๋ณด๋ธ ๋ฐ์ดํฐ๋ฅผ Nubison IoT ํ๋ซํผ์ ์ ์ฅํ ์ ์์ต๋๋ค.
์๋๋๋ผ์ด๋ฒ๋ฅผ ์ด์ฉํ์๋ ๊ฒฝ์ฐ ๋ค์๊ณผ ๊ฐ์ด ๋ฐ์ดํฐ๋ฅผ ๊ตฌ์ฑํ์๋ฉด ๋ฉ๋๋ค.
"|" ๋ก ๊ตฌ๋ถํ์ฌ ์ผ๋ จ์ ๋ฌธ์์ด๋ก ์ ์กํฉ๋๋ค. (์๋ ์์ฑ๋ ๋๋ผ์ด๋ฒ๋ฅผ ์ด์ฉํ๋ ๊ฒฝ์ฐ, ๋๋ฐ์ด์ค๊ฐ ๋ณด๋ธ ๋ฐ์ดํฐ๋ฅผ Nubison IoT ํ๋ซํผ ์๋ฒ์์ "|" ๋ก ๋ฐ์ดํฐ๋ฅผ ์๋ฅธ ํ ์ ๋ ๋ฒํธ ์์๋๋ก ๋ฐ์ดํฐ๋ฅผ ๋ฃ์ด ์ ์ฅํ๊ฒ ๋ฉ๋๋ค.)
์ซ์, ์์น ๋ฐ์ดํฐ๋ ์ซ์ ํฌ๋งท์ผ๋ก,
๋ฌธ์ ๋ฐ์ดํฐ๋ ๋ฌธ์ ํฌ๋งท์ผ๋ก,
์ซ์ ๋ฐฐ์ด ๋ฐ์ดํฐ๋ ","๋ก ์ฐ์ ํ ์ซ์
๋ฌธ์ ๋ฐฐ์ด ๋ฐ์ดํฐ๋ ","๋ก ์ฐ์ ํ ๋ฌธ์
์ด๋ฏธ์ง๋ base64๋ก ์ธ์ฝ๋ฉํ ์คํธ๋ง
๋ฐ์ดํฐ๋ฅผ ๋ค์๊ณผ ๊ฐ์ด ๋ณด๋ธ๋ค๋ฉด
ํ์ด๋ก๋๋ฅผ ๋ค์๊ณผ ๊ฐ์ด ๊ตฌ์ฑํด์ฃผ์๋ฉด ๋ฉ๋๋ค.