- 积分
- 174
- 金钱
- 140
- 威望
- 0
- 贡献
- 0
- HASS币
- 0
注册会员
- 积分
- 174
- 金钱
- 140
- HASS币
- 0
|
发表于 2022-9-24 12:45:21
|
显示全部楼层
本帖最后由 onions 于 2022-9-24 12:47 编辑
如果是payload 字段,默认就会以http请求 body的形式发送给接口, 至于如何处理,取决于你的接口的处理逻辑。
进一步,你的问题真正想表达的意思可能是,如何构造一个能让接口处理的请求http请求头。
首先你要知道你的接口类型是什么,有哪些请求参数,然后你需要构造一个符合接口要求的 http请求头。
这里涉及两个node 的配置 ,
第一步,你需要新增一个 change node 或function node ,在其中构造符合 接口要求的http请求头。
第二步, 你需要在http request node 中 配置 header 的conten-type类型为接口的类型。
如果还不明白,一个例子作参考,如下。
[{"id":"d25e24f7e03a1406","type":"tab","label":"Flow10","disabled":false,"info":"","env":[]},{"id":"71693b8bfde5b779","type":"inject","z":"d25e24f7e03a1406","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":100,"y":320,"wires":[["1abec6e3e32021a5"]]},{"id":"1abec6e3e32021a5","type":"change","z":"d25e24f7e03a1406","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"name\":\"Tom\",\"age\":16}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":320,"wires":[["fd14eaf6a15fa720"]]},{"id":"fd14eaf6a15fa720","type":"httprequest","z":"d25e24f7e03a1406","name":"","method":"POST","ret":"txt","paytoqs":"ignore","url":"http://127.0.0.1:1880/print","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[{"keyType":"Content-Type","keyValue":"","valueType":"application/json","valueValue":""}],"credentials":{},"x":510,"y":320,"wires":[["c2d07f8c296ca5be"]]},{"id":"c2d07f8c296ca5be","type":"debug","z":"d25e24f7e03a1406","name":"debug28","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":700,"y":320,"wires":[]}] |
|