gpt4 book ai didi

node-red - 无法将负载参数传递给 Node-RED http 请求

转载 作者:行者123 更新时间:2023-12-03 18:28:17 25 4
gpt4 key购买 nike

我正在尝试在 Node-RED 中执行简单的 http get 请求。根据在线文档,我必须传递函数中的参数作为 http 请求节点的输入。我的函数如下所示;

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;

但是,当我查看服务器响应时,我收到错误:

["{"error":{"message":"Missing topics parameter.","statusCode":400,"errorCode":"MC-Unknown","requestId":"RnY9E0pbcU1lkiaf"},"meta":null}"][1]

我尝试过其他 api,但还无法传递负载参数。

我做错了什么?

最佳答案

如果您想传递 GET 请求的查询参数,您应该在 http 请求节点 中设置基本 URL,并使用 Mustache 语法来包含它们:

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;

关于node-red - 无法将负载参数传递给 Node-RED http 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42596187/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com