Operación Bulk: Crear Devices

Este endpoint crea múltiples Devices nuevos.

Solicitud HTTP

Para crear múltiples Devices nuevos, haz una petición POST a la siguiente URL:

HTTP MethodURL
POSThttps://api.netux.com/api/v2.0/devices/_/bulk/create/

Parámetros de consulta

ParameterTypeUseDescription
tokenStringAuthenticationAuthentication Token can optionally be sent as a query parameter.

Parámetros de cuerpo

El cuerpo es un array que contiene objetos JSON Device. Cada objeto Device puede contener los siguientes parámetros de cuerpo:

ParameterTypeRequired?Default ValueDescription
labelStringYesN/A (required)API label of Device
nameStringNoSame as labelName of Device
descriptionStringNo""Description of Device
tagsString ArrayNo[ ]Device tags
propertiesObjectNo{ }Device properties. Allowed attributes: _icon, _color, _location_type,_location_variable (label of Variable) _location_fixed, _config
organizationStringNonullOrganization of Device

Cabecera

📘

No olvidar

Ten en cuenta que el atributo de cabecera X-Bulk-Operation es necesario.

ParameterRequired?Description
X-Auth-TokenYesAuthentication Token of account
X-Bulk-OperationBooleanNeed to be set to True for the bulk operation to work
Content-TypeString (application/json)Content type of body
curl -X POST 'https://api.netux.com/api/v2.0/devices/_/bulk/create/' \
 -H 'Content-Type: application/json' \
 -H 'X-Auth-Token: oaXBo6ODhIjPsusNRPUGIK4d72bc73' \
 -H 'X-Bulk-Operation: True' \
 -d '[
     {
            "label": "device_1",
            "properties": {
              "_location_type":"manual",
              "_location_fixed": { 
                  "lat": 6.2486, 
                  "lng": 75.5742 
                } 
            }
        },
        {
            "label": "device_2",
            "tags": ["Colombia", "Medellin", "IoTIsGreat"]
        },
        {
            "label": "device_3",
            "properties": {},
            "description":"This is the description for device_3"
        }
     ]'

Respuesta

Devuelve un Task Id del proceso asíncrono.

{
    "task": {
        "id": "5f208f564763e74744b2ba87"
    }
}
{
    "code": 400001,
    "message": "Validation Error.",
    "detail": {
        ....
    }
}
{
    "code": 401001,
    "message": "Authentication credentials were not provided.",
    "detail": "Authentication credentials were not provided."
}
{
    "detail": "Header `X-BULK-OPERATION` should be provided for bulk operation."
}