Queries the service call records of a specified device.
Usage notes
You can query only the service call records of the previous 30 days.
QPS limits
You can call this API operation up to 50 times per second per account.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
Action | String | Yes | QueryDeviceServiceData | The operation that you want to perform. Set the value to QueryDeviceServiceData. |
EndTime | Long | Yes | 1579249499000 | The end of the time range to query. The value is a Unix timestamp. Unit: milliseconds. Example: 1579249499000. |
StartTime | Long | Yes | 1579249499000 | The beginning of the time range to query. The value is a Unix timestamp. Unit: milliseconds. Example: 1579249499000. |
IotInstanceId | String | No | iot_instc_pu****_c*-v64******** | The ID of the instance. You can view the ID of the instance on the Overview page in the IoT Platform console. Important
For more information, see Overview. |
IotId | String | No | Q7uOhVRdZRRlDnTLv****00100 | The ID of the device. The ID is a unique identifier that is issued by IoT Platform to the device. Important The IotId parameter specifies a GUID for the device. The value of the IotId parameter is equivalent to a combination of the values of the ProductKey and DeviceName parameters. If you specify a value for this parameter, you do not need to configure the ProductKey or DeviceName parameter. If you specify values for the IotId, ProductKey, and DeviceName parameters, the value of the IotId parameter takes precedence. |
ProductKey | String | No | a1BwAGV**** | The ProductKey of the product to which the device belongs. Important If you specify a value for this parameter, you must configure the DeviceName parameter. |
DeviceName | String | No | light | The DeviceName of the device. Important If you specify a value for this parameter, you must configure the ProductKey parameter. |
Identifier | String | No | Set | The identifier of the service. The identifier of the service that is called. You can view the service identifier on the Define Feature tab in the IoT Platform console. You can also call the QueryThingModel operation to view the service identifier. Note If a service named testService belongs to a custom module named testFb, you can set this parameter to testFb:testService. The custom module is not the default module. If you do not specify a value for this parameter, the system queries all service data of the default module. |
Asc | Integer | No. | 0 | The sorting order of the returned service call records. Valid values:
|
PageSize | Integer | No | 10 | The number of entries to return on each page. Valid values: 1 to 50. |
In addition to the preceding operation-specific request parameters, you must configure common request parameters when you call this operation. For more information about common request parameters, see Common parameters.
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
Code | String | iot.system.SystemException | The error code that is returned if the call fails. For more information, see Error codes. |
Data | Struct | The service call records returned if the call is successful. | |
List | Array of ServiceInfo | The array of service call records. Each element represents a service call record. | |
ServiceInfo | |||
Identifier | String | Set | The identifier of the service. |
InputData | String | {\"LightAdjustLevel\":123} | The input parameter of the service. The value is a string in the MAP format. Syntax: |
Name | String | Set_Temperature | The name of the service. |
OutputData | String | {\"code\":200,\"data\":{},\"id\":\"100686\",\"message\":\"success\",\"version\":\"1.0\"} | The output parameter of the service. The value is a string in the MAP format. Syntax: |
Time | String | 1579249499000 | The time when the service was called. |
NextTime | Long | 1579335899000 | The start time of service call records on the next page. If you call the QueryDeviceServiceData operation to query the service call records on the next page, you must set the StartTime parameter to the value of this parameter. |
NextValid | Boolean | true | Indicates whether the next page exists.
If the return value of the NextValid parameter is true, you can use the value of the NextTime parameter as the value of the StartTime parameter when you query the next page of results. |
ErrorMessage | String | A system exception occurred. | The error message that is returned if the call fails. |
RequestId | String | E55E50B7-40EE-4B6B-8BBE-D3ED55CCF565 | The ID of the request. The ID uniquely identifies the request. |
Success | Boolean | true | Indicates whether the call was successful. Valid values:
|
Examples
Sample requests
https://iot.cn-shanghai.aliyuncs.com/?Action=QueryDeviceServiceData
&ProductKey=a1BwAGV****
&DeviceName=device1
&Identifier=set
&StartTime=1516538300303
&EndTime=1516541900303
&PageSize=10
&Asc=1
&<Common request parameters>
Sample success responses
XML
format
<QueryDeviceServiceDataResponse>
<Data>
<NextValid>true</NextValid>
<NextTime>1517315865197</NextTime>
<List>
<ServiceInfo>
<Name>set</Name>
<Time>1517315865198</Time>
<OutputData>{"code":200,"data":{},"id":"100686","message":"success","version":"1.0"}</OutputData>
<InputData>{"LightAdjustLevel":123}</InputData>
<Identifier>set</Identifier>
</ServiceInfo>
</List>
</Data>
<RequestId>A44C818E-FA7F-4765-B1E7-01D14AE01C6A</RequestId>
<Success>true</Success>
</QueryDeviceServiceDataResponse>
JSON
format
{
"Data": {
"NextValid": true,
"NextTime": 1517315865197,
"List": {
"ServiceInfo": [
{
"Name": "set",
"Time": 1517315865198,
"OutputData": "{\"code\":200,\"data\":{},\"id\":\"100686\",\"message\":\"success\",\"version\":\"1.0\"}",
"InputData": "{\"LightAdjustLevel\":123}",
"Identifier": "set"
}
]
}
},
"RequestId": "A44C818E-FA7F-4765-B1E7-01D14AE01C6A",
"Success": true
}
Error codes
For a list of error codes, see Service error codes.