【发布时间】:2020-02-25 17:06:57
【问题描述】:
使用 Node-Red,我正在尝试为 http 请求设置正确的参数,但我无法做到。
使用 curl 的查询是这样的:
curl -H "Content-Type: application/json" -X GET -d '{"auth_key":"xf79rra", "payload":null}' https://retepaiot.it/sensordata/0018b1213
它有效。
我认为我在传递 auth_key 和 payload 时做错了(它们不是 URL 参数)。 我使用函数来准备消息:
msg.headers = {
"Content-Type": "application/json"
};
msg.payload = {auth_key:"xf7xxxx9rra",
payload:null};
return msg;
和对 URL 的 http 请求:
https://retepaiot.it/sensordata/001xxxx1213
返回的消息是:
{ "message": "Failed to decode JSON object: Expecting value: line 1 column 1 (char 0)"}
【问题讨论】:
-
运行
curl命令时得到的响应是什么,它是JSON 字符串吗?错误是关于处理回复,而不是您发送的内容。 -
返回是 statusCode: 400 (Bad request)
-
表示错误是准确的,因为“statusCode: 400 (Bad request”不是JSON
-
是的,没错。问题是如何在 node-red 上填写请求。
标签: node-red