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
+44-20Lines changed: 44 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,10 +17,12 @@ The IoT Central REST API lets you develop client applications that integrate wit
17
17
- List jobs and view job details in your application.
18
18
- Create jobs in your application.
19
19
- Stop, resume, and rerun jobs in your application.
20
-
- Schedule Jobs and view scheduled job details in your application.
20
+
- Schedule jobs and view scheduled job details in your application.
21
+
22
+
Scheduled jobs are created to run at a future time. You can set a start date and time for a scheduled job to run one-time, daily, or weekly. Non-scheduled jobs run only one-time.
21
23
22
24
> [!IMPORTANT]
23
-
> The jobs API is currently in preview. All The REST API calls described in this article should include `?api-version=2022-06-30-preview`.
25
+
> The jobs API is currently in preview. All The REST API calls described in this article should include `?api-version=2022-07-31`.
24
26
25
27
This article describes how to use the `/jobs/{job_id}` API to control devices in bulk. You can also control devices individually.
26
28
@@ -92,7 +94,7 @@ The following table describes the fields in the previous JSON snippet:
92
94
Use the following request to retrieve the list of the jobs in your application:
93
95
94
96
```http
95
-
GET https://{your app subdomain}.azureiotcentral.com/api/jobs?api-version=2022-06-30-preview
97
+
GET https://{your app subdomain}.azureiotcentral.com/api/jobs?api-version=2022-07-31
96
98
```
97
99
98
100
The response to this request looks like the following example:
@@ -161,7 +163,7 @@ The response to this request looks like the following example:
161
163
Use the following request to retrieve an individual job by ID:
162
164
163
165
```http
164
-
GET https://{your app subdomain}.azureiotcentral.com/api/jobs/job-004?api-version=2022-06-30-preview
166
+
GET https://{your app subdomain}.azureiotcentral.com/api/jobs/job-004?api-version=2022-07-31
165
167
```
166
168
167
169
The response to this request looks like the following example:
@@ -196,7 +198,7 @@ The response to this request looks like the following example:
196
198
Use the following request to retrieve the details of the devices in a job:
197
199
198
200
```http
199
-
GET https://{your app subdomain}.azureiotcentral.com/api/jobs/job-004/devices?api-version=2022-06-30-preview
201
+
GET https://{your app subdomain}.azureiotcentral.com/api/jobs/job-004/devices?api-version=2022-07-31
200
202
```
201
203
202
204
The response to this request looks like the following example:
@@ -229,7 +231,7 @@ The response to this request looks like the following example:
229
231
Use the following request to create a job:
230
232
231
233
```http
232
-
PUT https://{your app subdomain}.azureiotcentral.com/api/jobs/job-006?api-version=2022-06-30-preview
234
+
PUT https://{your app subdomain}.azureiotcentral.com/api/jobs/job-006?api-version=2022-07-31
233
235
```
234
236
235
237
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.
@@ -238,7 +240,7 @@ The `group` field in the request body identifies a device group in your IoT Cent
238
240
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
241
240
242
```http
241
-
PUT https://{subdomain}.{baseDomain}/api/deviceGroups/group1?api-version=2022-06-30-preview
243
+
PUT https://{subdomain}.{baseDomain}/api/deviceGroups/group1?api-version=2022-07-31
242
244
```
243
245
244
246
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`.
@@ -324,31 +326,53 @@ The response to this request looks like the following example. The initial job s
324
326
Use the following request to stop a running job:
325
327
326
328
```http
327
-
POST https://{your app subdomain}.azureiotcentral.com/api/jobs/job-006/stop?api-version=2022-06-30-preview
329
+
POST https://{your app subdomain}.azureiotcentral.com/api/jobs/job-006/stop?api-version=2022-07-31
328
330
```
329
331
330
332
If the request succeeds, it returns a `204 - No Content` response.
331
333
332
334
Use the following request to resume a stopped job:
333
335
334
336
```http
335
-
POST https://{your app subdomain}.azureiotcentral.com/api/jobs/job-006/resume?api-version=2022-06-30-preview
337
+
POST https://{your app subdomain}.azureiotcentral.com/api/jobs/job-006/resume?api-version=2022-07-31
336
338
```
337
339
338
340
If the request succeeds, it returns a `204 - No Content` response.
339
341
340
342
Use the following command to rerun an existing job on any failed devices:
341
343
342
344
```http
343
-
PUT https://{your app subdomain}.azureiotcentral.com/api/jobs/job-006/rerun/rerun-001?api-version=2022-06-30-preview
345
+
PUT https://{your app subdomain}.azureiotcentral.com/api/jobs/job-006/rerun/rerun-001?api-version=2022-07-31
344
346
```
345
347
346
348
## Create a scheduled job
347
349
348
-
Use the following request to create a scheduled job
350
+
The payload for a scheduled job is similar to a standard job but includes the following additional fields:
351
+
352
+
| Field |Type| Description |
353
+
| ----- | --------| ----------- |
354
+
schedule|JobSchedule| The schedule at which to execute the job.
355
+
356
+
### JobSchedule
357
+
358
+
The schedule definition of job.
359
+
360
+
| Field |Type| Description |
361
+
| ----- | --------| ----------- |
362
+
end| `JobScheduleEnd`, `DateJobScheduleEnd`, `OccurrencesJobScheduleEnd`|The specification of when to end the scheduled job.
363
+
recurrence | `JobRecurrence`| The recurrence of the scheduled job. If not provided, the job will run once at the specified start time.
364
+
start| string |The start time for the scheduled job.
365
+
366
+
### JobRecurrence
367
+
368
+
| Field |Type| Description |
369
+
| ----- | --------| ----------- |
370
+
daily| string |The job will run once daily.
371
+
monthly| string| The job will run once every month.
372
+
weekly| string| The job will run once every week.
349
373
350
374
```http
351
-
PUT https://{your app subdomain}.azureiotcentral.com/api/scheduledJobs/scheduled-Job-001?api-version=2022-06-30-preview
375
+
PUT https://{your app subdomain}.azureiotcentral.com/api/scheduledJobs/scheduled-Job-001?api-version=2022-07-31
352
376
```
353
377
354
378
The following example shows a request body that creates a scheduled job.
@@ -400,10 +424,10 @@ The response to this request looks like the following example:
400
424
401
425
## Get a scheduled job
402
426
403
-
Use the following request to get a scheduled job
427
+
Use the following request to get a scheduled job:
404
428
405
429
```http
406
-
GET https://{your app subdomain}.azureiotcentral.com/api/scheduledJobs/scheduled-Job-001?api-version=2022-06-30-preview
430
+
GET https://{your app subdomain}.azureiotcentral.com/api/scheduledJobs/scheduled-Job-001?api-version=2022-07-31
407
431
```
408
432
409
433
The response to this request looks like the following example:
@@ -432,12 +456,12 @@ The response to this request looks like the following example:
432
456
}
433
457
```
434
458
435
-
## List Scheduled Jobs
459
+
## List scheduled jobs
436
460
437
-
Use the following request to get a list of scheduled jobs
461
+
Use the following request to get a list of scheduled jobs:
438
462
439
463
```http
440
-
GET https://{your app subdomain}.azureiotcentral.com/api/scheduledJobs?api-version=2022-06-30-preview
464
+
GET https://{your app subdomain}.azureiotcentral.com/api/scheduledJobs?api-version=2022-07-31
441
465
```
442
466
443
467
The response to this request looks like the following example:
@@ -492,10 +516,10 @@ The response to this request looks like the following example:
492
516
493
517
## Update a scheduled job
494
518
495
-
Use the following request to update a scheduled job
519
+
Use the following request to update a scheduled job:
0 commit comments