无法将有效负载参数传递给 Node-RED http 请求 [英] Unable to pass payload parameters to Node-RED http request

查看:116
本文介绍了无法将有效负载参数传递给 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;

这篇关于无法将有效负载参数传递给 Node-RED http 请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆