To assign one or more Devices to a Device Group, make a POST request to the following URL:
HTTP Method URL POST https://industrial.api.ubidots.com/api/v2.0/device_groups/<device_group_key>/_/assign_devices/
Parameter Type Description <device_group_key>String The ID or label of the Device Group, label should use the prefix ~
Parameter Type Use Description token String Authentication Authentication Token can optionally be sent as a query parameter. clear Boolean Assignment mode If true, all existing Devices will be replaced with the Devices sent in the request. If false, Devices sent in the request will be appended.
cURL (Request)
$ curl -X POST 'https://industrial.api.ubidots.com/api/v2.0/device_groups/<device_group_key>/_/assign_devices/' \
-H 'Content-Type: application/json' \
-H 'X-Auth-Token: oaXBo6ODhIjPsusNRPUGIK4d72bc73' \
-d '[
"5e1cc1e789f9bd33017e05f4",
"~test",
{"id": "5e1cc1e789f9bd33babababa"}
]'
Returns an object with a results array containing the devices assigned to the device group.
200 OK 400 Bad Request 401 Unauthorized
{
"count": 2,
"next": null,
"previous": null,
"results":[
{
"url": "https://industrial.api.ubidots.com/api/v2.0/devices/5e1cc1e789f9bd33017e05f4",
"id": "5e1cc1e789f9bd33017e05f4",
"label": "truck-v2",
"name": "Truck v2"
},
{
"url": "https://industrial.api.ubidots.com/api/v2.0/devices/5e1c8d9789f9bd33017e05e5",
"id": "5e1c8d9789f9bd33017e05e5",
"label": "test",
"name": "test"
},
{
"url": "https://industrial.api.ubidots.com/api/v2.0/devices/5e1c8d9789f9bd33017e05e5",
"id": "5e1cc1e789f9bd33babababa",
"label": "test2",
"name": "test2"
}
]
}{
"code": 400001,
"message": "Validation Error.",
"detail": {
....
}
}{
"code": 401001,
"message": "Authentication credentials were not provided.",
"detail": "Authentication credentials were not provided."
}