无法将有效负载参数传递给 Node-RED http 请求
我正在尝试在 Node-RED 中执行一个简单的 http get 请求.根据在线文档,我必须将函数中的参数作为 http 请求节点的输入传递.我的函数是这样的;
I am trying to do a simple http get request in Node-RED. According to online documentation I have to pass the parameters in a function as input for the http request node. My function looks like this;
msg.url = "https://api.socialstudio.radian6.com/v3/posts"
msg.method = "GET"
msg.headers = {'access_token': access_token}
msg.payload = {
'topics': 234243,
'limit': 100,
}
return msg;
但是,当我查看服务器响应时,出现错误:
However when i look at the server response i get the error:
["{"error":{"message":"Missing topics parameter.","statusCode":400,"errorCode":"MC-Unknown","requestId":"RnY9E0pbcU1lkiaf"},"meta":null}"][1]
我尝试了其他 api,但我还没有能够传递有效负载参数.
I have tried other api's but I have not yet been able to pass the payload parameters.
我做错了什么?
如果你想为 GET 请求传递查询参数,你应该在 http 请求节点
中设置基本 URL 并使用 mustache包含它们的语法:
If you want to pass query parameters for a GET request you should set the base URL in the http request node
and use the mustache syntax to include them:
https://api.socialstudio.radian6.com/v3/posts?topics={topics},limit={limts}
并将函数节点更改为:
msg.method = "GET"
msg.headers = {'access_token': access_token}
msg.topics = 234243;
msg.limit = 100;
return msg;