-
Notifications
You must be signed in to change notification settings - Fork 17
IoTHub Manager Jobs API
GET /v1/jobs
This API accepts five optional query strings:
-
jobType
- the type of job. There are two available values: -
- device method job (ScheduleDeviceMethod)
-
- update twin job (ScheduleUpdateTwin)
Both the number value and string value in brackets are acceptable
-
jobStatus
- the status of job. There are available values below:
- enqueued
- running
- completed
- failed
- cancelled
- scheduled
- queued
Both the number value and string value are acceptable
-
pageSize
- the page size of job query -
from
- the lower UTC time bound of interesting period. It accept time formats below:
- NOW
- NOW-{ISO8601 duration}
- NOW+{ISO8601 duration}
- Date time offset string. Please check MSDN for detail
-
to
- the upper UTC time bound of interesting period. The acceptable input format is same asfrom
Sample requests
-
/v1/jobs?jobStatus=running
Returns all running jobs
-
/v1/jobs?jobStatus=3&from=NOW-30D
Returns completed jobs created within last month
Response
Returns 200 OK and list of the job object. Please check API Get job status by job ID for detail of the job object
GET /v1/jobs/{id}
This API accepts two optional query strings:
-
includeDeviceDetails
-true
means request for per-device job details -
deviceJobStatus
- interestring job status of the per-device job details. The available values include:
- 0 - Pending
- 1 - Scheduled
- 2 - Running
- 3 - Completed
- 4 - Failed
- 5 - Canceled
Both the number value and string value are acceptable
Sample requests
-
/v1/jobs/job001
Returns cross device summary of job
job001
-
/v1/jobs/job001?includeDeviceDetails=true
Returns cross device summary and pre-device details of job
job001
-
/v1/jobs/job001?includeDeviceDetails=true&deviceJobStatus=failed
Returns cross device summary and failed pre-device details of job
job001
Response
Returns 200 OK and the job object:
{
"jobId": <job ID>,
"queryCondition": <the query condition used to schedule job>,
"createdTimeUtc": <scheduled job start time in UTC>,
"startTimeUtc": <job start time>,
"endTimeUtc": <job end time>,
"maxExecutionTimeInSeconds": <max execution time used to schedule job>,
"type": <job type>,
"status": <job status>,
"methodParameter": {
"name": <method name>,
"jsonPayload": <parameters in JSON>,
"responseTimeout": <response timeout>,
"connectionTimeout": <connection timeout>
},
"updateTwin: {
"deviceId": <device ID>,
"etag": <etag>,
"properties": {
"Reported": { ... },
"Desired": { ... },
},
"tags": { ... },
"isSimulated": <true for simulated device, otherwise false>
},
"failureReason": <if job failed, this represents a string containing the reason>,
"statusMessage": <represents a string containing a message with status about the job execution>,
"resultStatistics": {
"deviceCount": <number of devices in the job>,
"failedCount": <the number of failed jobs>,
"succeededCount": <the number of Successed jobs>,
"runningCount": <the number of running jobs>,
"pendingCount": <the number of pending (scheduled) jobs>
},
"Devices": [
{
"DeviceId": <device ID>,
"Status": <the per-device job status. Value range is same as query string `deviceJobStatus`>,
"StartTimeUtc": <start time of the job on current device>,
"EndTimeUtc": <end time of the job on current device>,
"CreatedTDateTimeUtc": <create time of the job on current device>,
"LastUpdatedDateTimeUtc": <last update time of the job on current device>,
"Outcome": {
"status": <method execution status>,
"jsonPayload": <method output>
},
"Error": {
"Code": <device job error code>,
"Description": <device job error description>
}
}
]
}
Reminder:
- Currently, it will never return any error (such as 404 Not Found) even if there is no such a job ID (depends on IoT Hub)
- Some of fields may be null depends on IoT Hub implementation
-
methodParameter
will only be meaningful for device method jobs -
updateTwin
will only be meaningful for update twin jobs -
Devices.Outcome
andDevices.Error
may be missing if no such output from the device
POST /v1/jobs
The body should be the job object contains fields below:
jobId
queryCondition
-
methodParameter
orupdateTwin
There are two more optional field are available:
-
startTimeUtc
(default value:now
) -
maxExecutionTimeInSeconds
(default vaule: 3600)
Here are some examples of the request body:
{
"jobId": "sampleJob001",
"queryCondition": "deviceId = 'CoolingSampleDevice003_685'",
"methodParameter": {
"name": "Reboot"
}
}
{
"jobId": "sampleJob002",
"queryCondition": "tags.Floor = '1F'",
"updateTwin": {
"tags": {
"Floor": "2F"
}
}
}
Response
Returns 200 OK and the full job object
GET /v1/deviceProperties
Response
Returns 200 OK and the definition object
{
"Tags": [
"IsSimulated"
],
"Reported": [
"Protocol",
"SupportedMethods",
"DeviceMethodStatus",
"FirmwareUpdateStatus",
"Type",
"Location",
"Latitude",
"Longitude",
"Firmware",
"Model"
],
"$metadata": {
"$type": "DeviceProperties;1",
"$url": "/v1/deviceProperties"
}
}```