HTTP API获取 MQTT上报数据
1.首先MQTT设备端 先订阅属性相关主题 $sys/{pid}/{device_name}/thing/property/get
$sys/121eVmuGjQ/test/thing/property/get
API请求后,设备端收到一个消息id 和 属性名 的json
此时需要发布响应数据到相关主题
$sys/{pid}/{device-name}/thing/property/get_reply |
$sys/121eVmuGjQ/test/thing/property/get_reply
请求和回复的id必须一致,code 0 表示请求成功
{"id": "22", "code": 0, "data": {"battery_percentage": 70 }
}
API模拟端,发起获取数据请求
{"url": "/thingmodel/query-device-property-detail","method": "post","header": {"Accept": "application/json, text/plain, */*","Content-Type": "application/json","authorization": "version=2022-05-01&res=userid%2F307649&et=1758513767&method=sha1&sign=2VsiAB5pjacczQxmywG1Q60QFmI%3D"},"query": {},"body": {"product_id": "121eVmuGjQ","device_name": "test","params": ["battery_percentage"]},"create_time": 1758511076434,"resp": "{\"code\":0,\"data\":{\"battery_percentage\":70},\"msg\":\"succ\",\"request_id\":\"3fadad1d8a33476688672b3464bdc783\"}","resp_http_code": 0,"api_name": "获取设备属性详情","run_time": 2401,"action": "/thingmodel/query-device-property-detail","ns": "app"
}
响应结果
{"code": 0,"data": {"battery_percentage": 70},"msg": "succ","request_id": "3fadad1d8a33476688672b3464bdc783"
}
使用HTTP调试工具获取设备属性测试
1.鉴权信息https://iot.10086.cn/doc/aiot/fuse/detail/1464
2.获取userid
3.获取accesskey
4.鉴权token生成
5.http在线工具
https://app.apifox.com/project/6165209
订阅会有id 回复也要用这个id,才能响应