Skip to content

Commit 7ce9bc2

Browse files
authored
Merge pull request #197522 from v-krishnag/restjob
update rest api jobs
2 parents 6d3e284 + 3457e19 commit 7ce9bc2

File tree

1 file changed

+36
-3
lines changed

1 file changed

+36
-3
lines changed

articles/iot-central/core/howto-manage-jobs-with-rest-api.md

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,17 +226,50 @@ The response to this request looks like the following example:
226226

227227
## Create a job
228228

229-
Use the following request to retrieve the details of the devices in a job:
229+
Use the following request to create a job:
230230

231231
```http
232232
PUT https://{your app subdomain}.azureiotcentral.com/api/jobs/job-006?api-version=1.2-preview
233233
```
234234

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+
235268
```json
236269
{
237270
"displayName": "Set target temperature",
238271
"description": "Set target temperature device property",
239-
"group": "833d7a7d-8f99-4e04-9e56-745806bdba6e",
272+
"group": "group1",
240273
"batch": {
241274
"type": "percentage",
242275
"value": 25
@@ -264,7 +297,7 @@ The response to this request looks like the following example. The initial job s
264297
"id": "job-006",
265298
"displayName": "Set target temperature",
266299
"description": "Set target temperature device property",
267-
"group": "833d7a7d-8f99-4e04-9e56-745806bdba6e",
300+
"group": "group1",
268301
"batch": {
269302
"type": "percentage",
270303
"value": 25

0 commit comments

Comments
 (0)