調用該介面將裝置自訂Topic資料寫入時序資料存放區。
使用說明
僅標準型和尊享型企業版執行個體下,支援調用該介面寫入時序資料。
時序資料存放區詳細說明,請參見配置時序資料存放區。
使用限制
調用該介面的每秒請求寫入資料數,由您購買執行個體下的時序資料存放區IOPS規格決定。詳細內容,請參見購買企業版執行個體和查看時序資料存放區IOPS。
調試
您可以在OpenAPI Explorer中直接運行該介面,免去您計算簽名的困擾。運行成功後,OpenAPI Explorer可以自動產生SDK程式碼範例。
請求參數
|
名稱 |
類型 |
是否必選 |
樣本值 |
描述 |
| Action | String | 是 | WriteDevicesHotStorageData | 系統規定參數。取值:WriteDevicesHotStorageData。 |
| IotInstanceId | String | 是 | iot-2w**** | 執行個體ID。您可在物聯網平台控制台的執行個體概覽頁面,查看當前執行個體的ID。 |
| Items | String | 是 | { "Power": { "value": "on", "time": 1524448722000 }, "WF": { "value": 23.6, "time": 1524448722000 } } | 寫入的資料,固定為如下JSON資料結構。
|
| UserTopic | String | 是 | user/a***/b*** | 自訂Topic。從 自訂Topic詳細說明,請參見自訂Topic。 |
| ProductKey | String | 否 | a1BwAGV**** | 裝置所屬的產品ProductKey。 重要 如果傳入該參數,需同時傳入DeviceName。 |
| DeviceName | String | 否 | device1 | 裝置的名稱。 重要 如果傳入該參數,需同時傳入ProductKey。 |
| IotId | String | 否 | y4u2weAI********HMle1234 | 裝置ID。 重要 IotId作為裝置唯一識別碼,和ProductKey與DeviceName組合是一一對應的關係。如果傳入該參數,則無需傳入ProductKey和DeviceName。如果您同時傳入IotId和ProductKey與DeviceName組合,則以IotId為準。 |
調用API時,除了本文介紹的該API的特有請求參數,還需傳入公用請求參數。公用請求參數說明,請參見公用參數文檔。
返回資料
名稱 |
類型 |
樣本值 |
描述 |
| Code | String | iot.system.SystemException | 調用失敗時,返回錯誤碼。詳細資料,請參見下文錯誤碼。 |
| ErrorMessage | String | 系統異常 | 調用失敗時,返回的出錯資訊。 |
| RequestId | String | E55E50B7-40EE-4B6B-8BBE-D3ED55CCF565 | 阿里雲為該請求產生的唯一識別碼。 |
| Success | Boolean | true | 是否調用成功。
|
樣本
請求樣本
http(s)://iot.cn-shanghai.aliyuncs.com/?Action=WriteDevicesHotStorageData
&IotInstanceId=iot-2w****
&Items={ "Power": { "value": "on", "time": 1524448722000 }, "WF": { "value": 23.6, "time": 1524448722000 } }
&UserTopic=user/a***/b***
$ProductKey=a1BwAGV****
$DeviceName=device1
&<公用請求參數>
正常返回樣本
XML格式
<WriteDevicesHotStorageDataResponse>
<RequestId>E55E50B7-40EE-4B6B-8BBE-D3ED55CCF565</RequestId>
<Success>true</Success>
</WriteDevicesHotStorageDataResponse>
JSON格式
{
"RequestId": "E55E50B7-40EE-4B6B-8BBE-D3ED55CCF565",
"Success": true
}
錯誤碼
|
HttpCode |
錯誤碼 |
錯誤資訊 |
描述 |
| 400 | iot.device.InvalidFormattedDeviceName | The DeviceName format is invalid. | 裝置名稱格式錯誤。 |
| 400 | iot.device.NullDeviceName | The DeviceName parameter cannot be empty. | 裝置名稱不可為空。 |
| 400 | iot.device.SetDevicePropertyFailed | An error occurred while setting the device properties. | 設定裝置屬性失敗。 |
| 400 | iot.prod.InvalidFormattedProductkey | The ProductKey format is invalid. | 入參產品ProductKey格式錯誤。 |
| 400 | iot.prod.NotExistedProduct | The specified product does not exist. | 指定的產品不存在。 |
| 400 | iot.prod.NullProductKey | The ProductKey parameter cannot be empty. | 入參產品ProductKey不可為空。 |
| 400 | iot.check.InvalidFormattedParameter | The parameter format is invalid. | 參數格式錯誤。 |
| 400 | iot.messagebroker.HALFCONN | The specified operation has failed. The device is in an inactive status. | 裝置處於非活躍可能心跳失敗。 |
| 400 | iot.messagebroker.OFFLINE | The specified operation has failed. The device is offline. | 由於裝置離線導致失敗。 |
| 400 | iot.prod.QueryProductAbilitiesFailed | An error occurred while querying the product features. | 擷取產品功能失敗。 |
| 400 | iot.system.IllegalRequest | The request parameter is invalid. | 非法的請求參數。 |
| 400 | iot.dataalgo.ScriptMethodNotFound | Method is not found in script. | 指令碼中方法找不到。 |
| 400 | iot.dataalgo.ScriptExecutionTimeout | Script execution timeout. | 指令碼執行逾時。 |
| 400 | iot.dataalgo.ScriptExecutionOomException | Script execution is out of memory. | 指令碼執行超出記憶體限制。 |
| 400 | Iot.Device.NotExistedDevice | The device does not exist. | 裝置不存在或未啟用。 |
| 400 | iot.device.InvalidIoTId | The specified device ID is invalid. | 裝置ID錯誤。 |
| 400 | iot.dataalgo.ScriptExecutionException | Script execution exception. | 指令碼執行異常。 |
| 400 | iot.prod.QueryPropertyNotFound | Query property not found. | 查詢屬性不存在。 |
| 400 | iot.dataalgo.ScriptDataFormatException | Script function result format is incorrect. | 指令碼格式不正確。 |
| 400 | iot.dataalgo.ScriptRelationNotExist | Script relation not exist. | 指令碼關係不存在。 |
| 400 | iot.tsl.TslParseError | TSLlParseError: %s. | TSL解析錯誤: %s。 |
| 400 | iot.tsl.InvalidFormattedTslError | The TSL format is invalid. | TSL格式錯誤。 |
| 400 | iot.tsl.InvalidHistoryTimestampError | The history timestamp is invalid. | 無效的歷史時間戳記。 |
| 400 | iot.storage.HotStorageCapacityNotEnough | The timeline storage capacity not enough. | 時序儲存容量不足。 |
| 400 | iot.storage.HotStorageIopsWriteNotEnough | The timeline storage write IOPS is not enough. | 時序儲存寫IOPS不足。 |
訪問錯誤中心查看更多錯誤碼。