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
+36-3Lines changed: 36 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -226,17 +226,50 @@ The response to this request looks like the following example:
226
226
227
227
## Create a job
228
228
229
-
Use the following request to retrieve the details of the devices in a job:
229
+
Use the following request to create a job:
230
230
231
231
```http
232
232
PUT https://{your app subdomain}.azureiotcentral.com/api/jobs/job-006?api-version=1.2-preview
233
233
```
234
234
235
+
The `group` field in the request body identifies a device group in your IoT Central application. A job uses a device group to identify the set of devices the job operates on.
236
+
237
+
238
+
If you don't already have a suitable device group, you can create one with REST API call. The following example creates a device group with `group1` as the group ID:
239
+
240
+
```http
241
+
PUT https://{subdomain}.{baseDomain}/api/deviceGroups/group1?api-version=1.2-preview
242
+
```
243
+
244
+
When you create a device group, you define a `filter` that selects the devices to include in 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" device template where the `provisioned` property is `true`.
245
+
246
+
```json
247
+
{
248
+
"displayName": "Device group 1",
249
+
"description": "Custom device group.",
250
+
"filter": "SELECT * FROM devices WHERE $template = \"dtmi:modelDefinition:dtdlv2\" AND $provisioned = true"
251
+
}
252
+
```
253
+
254
+
The response to this request looks like the following example:
255
+
256
+
```json
257
+
{
258
+
"id": "group1",
259
+
"displayName": "Device group 1",
260
+
"description": "Custom device group.",
261
+
"filter": "SELECT * FROM devices WHERE $template = \"dtmi:modelDefinition:dtdlv2\" AND $provisioned = true"
262
+
}
263
+
```
264
+
265
+
You can now use the `id` value from the response to create a new job.
266
+
267
+
235
268
```json
236
269
{
237
270
"displayName": "Set target temperature",
238
271
"description": "Set target temperature device property",
239
-
"group": "833d7a7d-8f99-4e04-9e56-745806bdba6e",
272
+
"group": "group1",
240
273
"batch": {
241
274
"type": "percentage",
242
275
"value": 25
@@ -264,7 +297,7 @@ The response to this request looks like the following example. The initial job s
264
297
"id": "job-006",
265
298
"displayName": "Set target temperature",
266
299
"description": "Set target temperature device property",
0 commit comments