How to get path params from http post url

Hi,

How to get path params from http post url. e.g. http://nodered:1880/post/{name}. I am trying through

msg.req.name

but its not working.

It is not cleare whether you are talking about the http in node or request node. I presume the in node.

From the sidebar help text of the http in node.

The node will listen on the configured path for requests of a particular type. The path can be fully specified, such as /user , or include named parameters that accept any value, such as /user/:name . When named parameters are used, their actual value in a request can be accessed under msg.req.params .

msg.req.params giving undefined error when I am using node.warn()

And how are you setting the path in the http in node config?
it should be /post/:name

Use a debug node and set it to complete msg output to see what you are actually posting in the params.

There is an example in the Node-red website Cookbook that you can import and study

Handle url parameters in an HTTP endpoint

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.