在节点红色中向HTTP注入文本

时间:2015-06-15 19:19:58

标签: ibm-cloud

请在下面找到一个简单的节点红色流,用于文本注入到HTTP。 不知怎的,这个简单的流程不起作用。有任何想法吗? 10X

[ 
  {
    "id":"78a282df.875d7c",
    "type":"http in",
    "name":"http in",
    "url":"/sam",
    "method":"get",
    "x":146,
    "y":154,
    "z":"b93245a4.46cdb8",
    "wires": [["a40ab436.5bf548"]]
  },
  {
     "id":"2e6d576f.d192a8",
     "type":"template",
     "name":"",
     "field":"",
     "template":" {{ msg.payload }}",
     "x":469.00006103515625,
     "y":179,
     "z":"b93245a4.46cdb8",
     "wires":[["e206965a.1df968"]]
   },
   {
     "id":"e206965a.1df968",
     "type":"http response",
     "name":"http response",
     "x":643,
     "y":129.00003051757812,
     "z":"b93245a4.46cdb8",
     "wires":[]
   },
   {
     "id":"cf597c3c.30a68",
     "type":"inject",
     "name":"Inject1",
     "topic":"payload",
     "payload":"Injection",
     "payloadType":"string",
     "repeat":"",
     "crontab":"",
     "once":false,
     "x":155.00003051757812,
     "y":79,
     "z":"b93245a4.46cdb8",
     "wires":[["a40ab436.5bf548"]]
   },
   {
     "id":"d773e361.288c2",
     "type":"debug",
     "name":"Debug1",
     "active":true,
     "console":"false",
     "complete":"true",
     "x":578.0000610351562,
     "y":49,
     "z":"b93245a4.46cdb8",
     "wires":[]
   },
   {
     "id":"a40ab436.5bf548",
     "type":"function",
     "name":"",
     "func":"return {payload:msg.payload};\n",
     "outputs":1,
     "valid":true,
     "x":306,
     "y":111,
     "z":"b93245a4.46cdb8",
     "wires":[["2e6d576f.d192a8","d773e361.288c2"]]
   }
]

1 个答案:

答案 0 :(得分:4)

您的流量存在一些问题。

  1. Function节点没有通过它收到的消息对象 - 它只返回一个只有有效负载的新消息对象。这意味着HTTP In节点提供的原始请求/响应对象不会传递到HTTP响应节点。这意味着流程无法回复原始请求。

  2. 模板节点正在尝试插入{{ msg.payload }}。根据节点侧栏帮助中的示例,它应该只是{{ payload }}