Activate a new sensor
POST
/sensors
Header Parameters
- AuthorizationstringrequiredExample
{ "Authorization": "Bearer {jwt token}" }Description
Body Parameters
- bodyobjectrequiredExample
{ "hw_serial": "SE01000000", "activation_code": "AAAA-BBBB-CCCC-DDDD" }- hw_serialstringrequiredDescription
- activation_codestringrequiredDescription
Responses
201
- object
- _idstring
- hw_serialstringExample
- statusnumberExample
- user_idstring
- fw_versionstring
- sensor_profileobjectExample
{ "label": "My sensor", "street_and_number": "Flurstrasse 30", "zip_code": 8048, "city": "Zürich", "country": "sui" } - sensor_typestringExample
400
- object
- namestringExampleDescription
- messagestringExampleDescription
- codenumberExampleDescription
- classNamestringExampleDescription
- datastringDescription
- errorsobject[]Example
[ "detailed description of error" ]
Description
401
- object
- namestringExampleDescription
- messagestringExampleDescription
- codenumberExampleDescription
- classNamestringExampleDescription
- errorsobjectDescription
curl
curl --request POST \
--url /sensors \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'authorization: {"Authorization":"Bearer {jwt token}"}' \
--data '{
"hw_serial": "",
"activation_code": ""
}'javascript
var myHeaders = new Headers();
myHeaders.append("accept", "application/json");
myHeaders.append("content-type", "application/json");
myHeaders.append("authorization", "{\"Authorization\":\"Bearer {jwt token}\"}");
var raw = JSON.stringify({
"hw_serial": "",
"activation_code": ""
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("/sensors", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));ruby
require "uri"
require "json"
require "net/http"
url = URI("/sensors")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["accept"] = "application/json"
request["content-type"] = "application/json"
request["authorization"] = "{\"Authorization\":\"Bearer {jwt token}\"}"
request.body = JSON.dump({
"hw_serial": "",
"activation_code": ""
})
response = http.request(request)
puts response.read_body
python
import requests
import json
url = "/sensors"
payload = json.dumps({
"hw_serial": "",
"activation_code": ""
})
headers = {
'accept': 'application/json',
'content-type': 'application/json',
'authorization': '{"Authorization":"Bearer {jwt token}"}'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
201
// Created
{
"_id": "",
"hw_serial": "SE01000000",
"status": 1,
"user_id": "",
"fw_version": "",
"sensor_profile": {},
"sensor_type": "clemap_lm"
}400
// Bad Request
{
"name": "BadRequest",
"message": "Data does not match schema",
"code": 400,
"className": "bad-request",
"data": "",
"errors": [
{}
]
}401
// Unauthorized
{
"name": "NotAuthenticated",
"message": "Not authenticated",
"code": 401,
"className": "not-authenticated",
"errors": {}
}Activate a new sensor with an activation code