『瀚思彼岸』» 智能家居技术论坛

 找回密码
 立即注册
查看: 901|回复: 3

[流程系列] 请问下node-red下,post请求的请求参数怎么填?

[复制链接]

3

主题

64

帖子

329

积分

中级会员

Rank: 3Rank: 3

积分
329
金钱
265
HASS币
0
发表于 2024-2-19 14:26:59 | 显示全部楼层 |阅读模式
这是个通知停水的nr流
链接:weixin.yjsswjt.com
请求头:
POST /ArticleHandle/GetAllByType.ashx HTTP/1.1
Host: weixin.yjsswjt.com
Connection: keep-alive
Content-Length: 40
Accept: application/json, text/javascript, */*; q=0.01
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Linux; Android 8.0.0; ONEPLUS A3010 Build/OPR1.170623.032; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/116.0.0.0 Mobile Safari/537.36 XWEB/1160065 MMWEBSDK/20231202 MMWEBID/6562 MicroMessenger/8.0.47.2560(0x28002F35) WeChat/arm64 Weixin NetType/WIFI Language/zh_CN ABI/arm64
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Origin: http://weixin.yjsswjt.com
Referer: http://weixin.yjsswjt.com/Static/StopWaterNotice.html
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7
请求参数:
type=StopWater&flag=true&index=10&page=0

我的NR流:
[{"id":"6ed9a0705ba0e2e2","type":"debug","z":"f98c2b4faf025d2e","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":740,"y":200,"wires":[]},{"id":"f8ea0fc97d03ff04","type":"http request","z":"f98c2b4faf025d2e","name":"","method":"POST","ret":"txt","paytoqs":"ignore","url":"https://weixin.yjsswjt.com/ArticleHandle/GetAllByType.ashx","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[{"keyType":"Content-Type","keyValue":"","valueType":"other","valueValue":"application/x-www-form-urlencoded; charset=UTF-8"},{"keyType":"Accept","keyValue":"","valueType":"other","valueValue":"application/json, text/javascript, */*; q"},{"keyType":"Accept-Encoding","keyValue":"","valueType":"other","valueValue":"gzip, deflate"},{"keyType":"Accept-Language","keyValue":"","valueType":"other","valueValue":"zh-CN,zh;q"},{"keyType":"User-Agent","keyValue":"","valueType":"other","valueValue":"Mozilla/5.0 (Linux; Android 8.0.0; ONEPLUS A3010 Build/OPR1.170623.032; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/116.0.0.0 Mobile Safari/537.36 XWEB/1160065 MMWEBSDK/20231202 MMWEBID/6562 MicroMessenger/8.0.47.2560(0x28002F35) WeChat/arm64 Weixin NetType/WIFI Language/zh_CN ABI/arm64"},{"keyType":"other","keyValue":"Content-Length","valueType":"other","valueValue":"40"},{"keyType":"other","keyValue":"Host","valueType":"other","valueValue":"weixin.yjsswjt.com"},{"keyType":"other","keyValue":"Origin","valueType":"other","valueValue":"http://weixin.yjsswjt.com"},{"keyType":"other","keyValue":"Referer","valueType":"other","valueValue":"http://weixin.yjsswjt.com/Static/StopWaterNotice.html"}],"x":520,"y":200,"wires":[["6ed9a0705ba0e2e2"]]},{"id":"c59d66a2ed950942","type":"inject","z":"f98c2b4faf025d2e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":150,"y":200,"wires":[["0d3cebd6ed032b20"]]},{"id":"0d3cebd6ed032b20","type":"function","z":"f98c2b4faf025d2e","name":"准备post数据","func":"msg.payload = {\n    'type': 'StopWater',\n    'flag': 'true',\n    'index': '10',\n    'page': '0'\n};\nreturn msg;\n","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":330,"y":200,"wires":[["f8ea0fc97d03ff04"]]}]
报错,请问请求参数和变量应该如何填写?
回复

使用道具 举报

3

主题

64

帖子

329

积分

中级会员

Rank: 3Rank: 3

积分
329
金钱
265
HASS币
0
 楼主| 发表于 2024-2-19 14:53:31 | 显示全部楼层
<html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.20.2</center>
</body>
</html>
回复

使用道具 举报

3

主题

64

帖子

329

积分

中级会员

Rank: 3Rank: 3

积分
329
金钱
265
HASS币
0
 楼主| 发表于 2024-2-19 14:54:39 | 显示全部楼层
[{"id":"4a295a2330ebd105","type":"http request","z":"f98c2b4faf025d2e","name":"","method":"POST","ret":"obj","paytoqs":"ignore","url":"https://weixin.yjsswjt.com/ArticleHandle/GetAllByType.ashx","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":480,"y":420,"wires":[["6acd46c7a2f0ebde"]]},{"id":"a4acf0d8a0f78cfc","type":"inject","z":"f98c2b4faf025d2e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":420,"wires":[["44cd7ec9520fe819"]]},{"id":"6acd46c7a2f0ebde","type":"debug","z":"f98c2b4faf025d2e","name":"debug 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":660,"y":420,"wires":[]},{"id":"44cd7ec9520fe819","type":"function","z":"f98c2b4faf025d2e","name":"准备post数据","func":"msg.payload = 'type=StopWater&flag=true&index=10&page=0';\nmsg.headers = {\n    'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',\n    'Accept': 'application/json, text/javascript, */*; q=0.01', // 补充了 q 的值\n    'Accept-Encoding': 'gzip, deflate',\n    'Accept-Language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7',\n    'Connection': 'keep-alive',\n    'X-Requested-With': 'XMLHttpRequest',\n    'Content-Length': '40',\n    'Cookie': 'ASP.NET_SessionId=boufslsu2ounpri1rhub32hw',\n    'Host': 'weixin.yjsswjt.com',\n    'Origin': 'http://weixin.yjsswjt.com',\n    'Referer': 'http://weixin.yjsswjt.com/Static/StopWaterNotice.html',\n    'AUser-Agent': 'Mozilla/5.0 (Linux; Android 8.0.0; ONEPLUS A3010 Build/OPR1.170623.032; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/116.0.0.0 Mobile Safari/537.36 XWEB/1160065 MMWEBSDK/20231202 MMWEBID/6562 MicroMessenger/8.0.47.2560(0x28002F35) WeChat/arm64 Weixin NetType/WIFI Language/zh_CN ABI/arm64'\n};\nreturn msg;\n","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":310,"y":500,"wires":[["4a295a2330ebd105"]]}]
回复

使用道具 举报

12

主题

249

帖子

1995

积分

金牌会员

Rank: 6Rank: 6

积分
1995
金钱
1746
HASS币
10
QQ
发表于 2024-2-26 16:40:16 | 显示全部楼层
msg.headers = {
    'Content-Type': 'application/x-www-form-urlencoded'
};
msg.payload = "type=StopWater&flag=true&index=10&page=0";

return msg;

其他头信息自己添加
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-12-22 22:25 , Processed in 0.087107 second(s), 26 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表