3

我只是通过在命令行上编写这个命令来向我的设备发送一些数据

curl -v -X POST -d "{\"temperature\": 25}" http://demo.thingsboard.io/devices/api/v1/IG4XXXXXXXXXCQM/telemetry
--header "Content-Type:application/json"

但我最后收到此错误消息

{"timestamp":"2020-01-16T13:09:05.031+0000","status":405,"error":"Method Not Allowed","message":"Request method 'POST' not supported","path":"/devices/api/v1/IG4Dxxxxxxxxxxxxxxxxs6CCQM/telemetry"}* Connection #0 to host demo.thingsboard.io left intact

我做错了什么?感谢所有的努力以下是文档和整个错误消息

东西板

Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying 104.196.24.70:80...
* TCP_NODELAY set
* Connected to demo.thingsboard.io (104.196.24.70) port 80 (#0)
> POST /devices/api/v1/IGxxxxxxxs6CCQM/telemetry HTTP/1.1
> Host: demo.thingsboard.io
> User-Agent: curl/7.65.1
> Accept: */*
> Content-Type:application/json
> Content-Length: 19
>
* upload completely sent off: 19 out of 19 bytes
* Mark bundle as not supporting multiuse
< HTTP/1.1 405
< Allow: GET, HEAD
< X-Content-Type-Options: nosniff
< X-XSS-Protection: 1; mode=block
< Cache-Control: no-cache, no-store, max-age=0, must-revalidate
< Pragma: no-cache
< Expires: 0
< Content-Type: application/json;charset=UTF-8
< Content-Language: en
< Transfer-Encoding: chunked
< Date: Thu, 16 Jan 2020 13:09:04 GMT
<
{"timestamp":"2020-01-16T13:09:05.031+0000","status":405,"error":"Method Not Allowed","message":"Request method 'POST' not supported","path":"/devices/api/v1/IGxxxxxxxxxxxs6CCQM/telemetry"}* Connection #0 to host demo.thingsboard.io left intact
4

1 回答 1

1

您需要在您的 URL 中将 'device' 替换为 'api',以防您使用访问令牌,因此,而不是

curl -v -X POST -d "{\"temperature\": 25}" http://demo.thingsboard.io/devices/api/v1/IG4XXXXXXXXXCQM/telemetry
--header "Content-Type:application/json"

你需要使用

curl -v -X POST -d "{\"temperature\": 25}" http://demo.thingsboard.io/api/v1/IG4XXXXXXXXXCQM/telemetry
--header "Content-Type:application/json"
于 2020-01-21T14:06:30.243 回答