...
Expand | ||
---|---|---|
| ||
| ||
Expand | ||
| ||
Code Block | | |
|
----- # :: CASE - Create Tag |
with |
addition |
columns |
:: |
columns |
:: |
name (varchar, 80), location (varchar, 40) :: data format :: { :: "tag":[ :: ["sensor01", "3F-101"], :: ["sensor02", "3F-102"] :: ] :: } curl -k -X POST %URL% -H %CONTENT_HEADER% -H %API_HEADER% -d "{\"tag\":[[\"sensor01\",\"3F-101\"],[\"sensor02\",\"3F-102\"]]}" :: Return Format :: { :: "success":true, :: "reason":"create tag success", :: "data":{ :: |
" |
success_count":2, |
:: |
" |
tag":[ :: |
|
|
|
|
|
|
{ |
:: |
|
"location":"3F-101", :: " |
name":"sensor01" |
:: |
|
|
|
|
}, :: |
|
{ |
:: |
" |
location":" |
3F-102" |
,
|
:: |
"name":" |
sensor02" :: } :: ] |
:: } |
:: } |
:: ------------------------------------------------------------------------------------------------- # |
:: CASE - Create exist Tag |
|
:: data format |
:: { |
:: "tag":[ |
["sensor1"]] :: } curl -k -X POST %URL% |
-H %CONTENT_HEADER% -H %API_HEADER% -d "{\"tag\":[[\"sensor1\"]]}"
:: Return Format
:: status code:400 Bad Request
:: {
:: "success":false,
:: "reason":"Metadata key (sensor1) of TAGDATA table is already inserted."
:: } |
Expand | |||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||||||||||||
| |||||||||||||||||||||||
Expand | |||||||||||||||||||||||
| |||||||||||||||||||||||
Code Block | | ||||||||||||||||||||||
|
["sensor01", "3F-101"], # ["sensor02", "3F-102"] # ] # } curl -k -X POST $URL -H $CONTENT_HEADER -H $API_HEADER -d "{\"tag\":[[\"sensor01\",\"3F-101\"],[\"sensor02\",\"3F-102\"]]}" # Return Format # { # "success":true, # "reason":"create tag success", # "data":{ # "success_count":2, # "tag":[ # { # "location":"3F-101", # |
|
|
"name":"sensor01" # |
}, # |
{ # |
|
|
|
"location":"3F-102", # |
|
|
|
|
"name":"sensor02" # } # |
] # } # } # |
------------------------------------------------------------------------------------------------- #
# CASE - Create exist Tag
# data format
# {
# "tag":[["sensor1"]]
# }
curl -k -X POST $URL -H $CONTENT_HEADER -H $API_HEADER -d "{\"tag\":[[\"sensor1\"]]}"
# Return Format
# status code:400 Bad Request
# {
# "success":false,
# "reason":"Metadata key (sensor1) of TAGDATA table is already inserted."
# }
|
Expand | |||||||||
---|---|---|---|---|---|---|---|---|---|
| |||||||||
| |||||||||
Expand | |||||||||
| |||||||||
Code Block | | ||||||||
|
url: URL,
headers: {
"Content-Type": "application/json",
"x-api-key": API_KEY
},
body: JSON.stringify(Data)
},
function(error, response, body) {
console.log(body);
// Return Format
// {
// "success":true,
// "reason":"create tag success",
// "data":{
// "success_count":2,
// "tag":[
// {"name":"sensor1"},
// {"name":"sensor2"}
// ]
// }
// }
})
/* ------------------------------------------------------------------------------------------------- */
// CASE - create TAG with addition columns
var Data = {
tag: [
["sensor01", "3F-101"],
["sensor02", "3F-102"]
]
}
request.post({
url: URL,
headers: {
"Content-Type": "application/json",
"x-api-key": API_KEY
},
body: JSON.stringify(Data)
},
function(error, response, body) {
console.log(body);
// Return Format
// {
// "success":true,
// "reason":"create tag success",
// "data":{
// "success_count":2,
// "tag":[
// {
// "location":"3F-101",
// "name":"sensor01"
// },
// {
// "location":"3F-102",
// "name":"sensor02"
// }
// ]
// }
// }
})
/* ------------------------------------------------------------------------------------------------- */
// CASE - Create exist Tag
var Data = {
tag: [
["sensor1"]
]
}
request.post({
url: URL,
headers: {
"Content-Type": "application/json",
"x-api-key": API_KEY
},
body: JSON.stringify(Data)
},
function(error, response, body) {
console.log(body);
// Return Format
// status code:400 Bad Request
// {
// "success":false,
// "reason":"Metadata key (sensor1) of TAGDATA table is already inserted."
// }
})
|
Expand | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|