#onenet网络请求http(GET,POST)

时间:2024-03-17 19:01:26

参考博文:

POST:

https://blog.csdn.net/qq_43350239/article/details/104361153

POST请求(用串口助手测试):

POST /devices/1105985351/datapoints HTTP/1.1
api-key:AdbrV5kCRsKsRCfjboYOCVcF9FY=
Host:api.heclouds.com
Connection:close
Content-Length:58

{"datastreams":[{"id":"ppm","datapoints":[{"value":10}]}]}

GET请求

 获取云平台指定设备的所有数据流的值

GET /devices/1105985351/datapoints HTTP/1.1
api-key:AdbrV5kCRsKsRCfjboYOCVcF9FY=
Host:api.heclouds.com
Connection:close

//空两行

获取指定设备的指定数据流:

GET /devices/1105985351/datastreams/ppm HTTP/1.1
api-key:AdbrV5kCRsKsRCfjboYOCVcF9FY=
Host:api.heclouds.com
Connection:close

GET请求成功示例: 

+IPD,376:HTTP/1.1 200 OK
Date: Fri, 08 Mar 2024 11:36:30 GMT
Content-Type: application/json
Content-Length: 138
Connection: close
Access-Control-Allow-Headers: *
Access-Control-Allow-Origin: *
Server: Apache-Coyote/1.1
Pragma: no-cache

{"errno":0,"data":{"update_at":"2023-07-11 09:23:17","id":"haiba","create_time":"2023-07-10 14:29:05","current_value":238},"error":"succ"}CLOSED