节点红色集获取http请求参数

问题描述 投票:0回答:1

使用Node-Red,我试图为http请求设置正确的参数,但无法执行。

the block used

Function code

Http request setting

带有curl的查询是这样:

curl -H "Content-Type: application/json" -X GET -d '{"auth_key":"xf79rra", "payload":null}' https://retepaiot.it/sensordata/0018b1213

并且有效。

我认为传递auth_key和有效负载(它们不是URL参数)是错误的。我使用该函数准备消息:

msg.headers = {    
    "Content-Type": "application/json"
    };


msg.payload = {auth_key:"xf7xxxx9rra", 
    payload:null};
return msg;

和http请求URL:

https://retepaiot.it/sensordata/001xxxx1213

返回的消息是:

{ "message": "Failed to decode JSON object: Expecting value: line 1 column 1 (char 0)"}
node-red
1个回答
0
投票

查看节点配置底部的“返回类型”,您已明确要求JSON对象

© www.soinside.com 2019 - 2024. All rights reserved.