You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/iot-central/core/howto-manage-jobs-with-rest-api.md
+47-4Lines changed: 47 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -232,15 +232,58 @@ Use the following request to retrieve the details of the devices in a job:
232
232
PUT https://{your app subdomain}.azureiotcentral.com/api/jobs/job-006?api-version=1.2-preview
233
233
```
234
234
235
-
The following request body requires the `group` of the device group that the job applies to. You can use the [get list of device groups](howto-manage-devices-with-rest-api.md#List-device-groups) REST API to get a list of the device groups in your application and use the required `group` from the response to create a new job.
235
+
The request body requires the `group` of the device group that the job applies to.
236
+
237
+
Use the following request to create a new device group.
238
+
239
+
```http
240
+
PUT https://{subdomain}.{baseDomain}/api/deviceGroups/{deviceGroupId}?api-version=1.2-preview
241
+
```
242
+
243
+
When you create a device group, you define a `filter` that selects the devices to add to the group. A `filter` identifies a device template and any properties to match. The following example creates device group that contains all devices associated with the "dtmi:modelDefinition:dtdlv2" template where the `provisioned` property is true
244
+
245
+
```json
246
+
{
247
+
"displayName": "Device group 1",
248
+
"description": "Custom device group.",
249
+
"filter": "SELECT * FROM devices WHERE $template = \"dtmi:modelDefinition:dtdlv2\" AND $provisioned = true",
250
+
"organizations": [
251
+
"seattle"
252
+
]
253
+
}
254
+
```
255
+
256
+
The request body has some required fields:
257
+
258
+
-`@displayName`: Display name of the device group.
259
+
-`@filter`: Query defining which devices should be in this group.
260
+
-`@etag`: ETag used to prevent conflict in device updates.
261
+
-`description`: Short summary of device group.
262
+
263
+
The organizations field is only used when an application has an organization hierarchy defined. To learn more about organizations, see [Manage IoT Central organizations](howto-edit-device-template.md)
264
+
265
+
The response to this request looks like the following example:
266
+
267
+
```json
268
+
{
269
+
"id": "group1",
270
+
"displayName": "Device group 1",
271
+
"description": "Custom device group.",
272
+
"filter": "SELECT * FROM devices WHERE $template = \"dtmi:modelDefinition:dtdlv2\" AND $provisioned = true",
273
+
"organizations": [
274
+
"seattle"
275
+
]
276
+
}
277
+
```
278
+
279
+
You can now use the `id` value from the response to create a new job.
236
280
237
-
You can also [create a new device group](howto-manage-devices-with-rest-api.md#add-a-device-group) and use the value of the `ID` from the device group you created.
238
281
239
282
```json
240
283
{
241
284
"displayName": "Set target temperature",
242
285
"description": "Set target temperature device property",
243
-
"group": "833d7a7d-8f99-4e04-9e56-745806bdba6e",
286
+
"group": "group1",
244
287
"batch": {
245
288
"type": "percentage",
246
289
"value": 25
@@ -268,7 +311,7 @@ The response to this request looks like the following example. The initial job s
268
311
"id": "job-006",
269
312
"displayName": "Set target temperature",
270
313
"description": "Set target temperature device property",
0 commit comments