Este endpoint crea un nuevo Device.
Solicitud HTTP
Para crear un nuevo Device, haz una petición POST a la siguiente URL:
HTTP Method | URL |
---|---|
POST | https://api.netux.com/api/v2.0/devices/ |
Parámetros de consulta
Parameter | Type | Use | Description |
---|---|---|---|
token | String | Authentication | Authentication Token can optionally be sent as a query parameter |
Parámetros de cuerpo
Parameter | Type | Required? | Default Value | Description |
---|---|---|---|---|
label | String | Yes | N/A (required) | API label of Device |
name | String | No | Same as label | Name of Device |
description | String | No | "" | Description of Device |
tags | String Array | No | [ ] | Device tags |
properties | Object | No | { } | Device properties. Allowed attributes: _icon , _color , _location_type , _location_variable (label of Variable), _location_fixed , _config |
organization | String | No | null | Organization of Device |
Atributo
properties
explicado
_icon
: ícono de la Variable (FontAwesome)
_color
: HEX, RGB y RGBA.
_location_type
: determina el tipo de localización, valores permitidos:manual
,specified
oauto
. Más información.
_location_variable
: label de la Variable que contiene las coordenadas GPS (para_location_type:specified
)
_location_fixed
: objeto con las keyslat
ylng
que contiene las coordenadas GPS (para_location_type:manual
)
_config
: véase más abajo
_config
Todos los datos de configuración de cada propiedad se guardan como un atributo de objeto en la key _config. Esta configuración contiene el tipo de propiedad, el nombre amigable que se mostrará en el front-end y la descripción que se mostrará también en el front-end.
_config: { propertyKey: { text: string, // Property Key friendly name type: string: "boolean"|"date"|"list"|"text"|"number", description: string, // Description of the property key options?: array<string>, // This is passed in case the type is list value: string, // Default value } }
Cabecera
Parameter | Required? | Description |
---|---|---|
X-Auth-Token | Yes | Authentication Token of account |
Content-Type | String (application/json) | Content type of body |
curl -X POST 'https://api.netux.com/api/v2.0/devices/' \
-H 'Content-Type: application/json' \
-H 'X-Auth-Token: oaXBo6ODhIjPsusNRPUGIK4d72bc73' \
-d '{"label": "arduino",
"properties": {
"_location_type":"manual",
"_location_fixed": {
"lat": 6.2486,
"lng": 75.5742
}
}
}'
Respuesta
Devuelve un objeto Device del Device creado.
{
"id": "ac5e948a581a9bb541a43feee",
"label": "second-device",
"name": "Second Device",
"description": "other description",
"isActive": true,
"lastActivity": null,
"organization": null,
"position": {},
"tags": ["first"],
"properties": {
"_location_fixed": {
"lat": 6.2486,
"lng": 75.5742
}
},
"url": "http://api.netux.com/api/v2.0/devices/ac5e948a581a9bb541a43feee",
"variables": "http://api.netux.com/api/v2.0/devices/ac5e948a581a9bb541a43feee/variables",
"variablesNumber": 0,
"createdAt": "2019-11-25T19:35:08.975270Z"
}
{
"code": 400001,
"message": "Validation Error.",
"detail": {
....
}
}
{
"code": 401001,
"message": "Authentication credentials were not provided.",
"detail": "Authentication credentials were not provided."
}