# Multiple path parameters on http in node for api

**URL:** https://discourse.nodered.org/t/multiple-path-parameters-on-http-in-node-for-api/79404
**Category:** General
**Created:** [25 June 2023 14:49 UTC](https://discourse.nodered.org/t/multiple-path-parameters-on-http-in-node-for-api/79404 "2023-06-25T14:49:54Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![hughsheehy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hughsheehy/32/58679_2.png) [@hughsheehy](https://discourse.nodered.org/u/hughsheehy)
#### Post date: [25 June 2023 14:49 UTC](https://discourse.nodered.org/t/multiple-path-parameters-on-http-in-node-for-api/79404/1 "2023-06-25T14:49:54Z")

</div>

Possibly a silly question.

I am trying to write an api with the http in node. I want to use path parameters so that I can have an api path that is - for instance - in the form api/:color/:shape

Is it possible to have more than one path parameter on the http in node? I can do it with query parameters, but path would be nicer for others in the team.

When I try it, it's easy to do the api/:color part, but as soon as I try anything with a second path parameter I just get no response at all. And nothing even in the debug node in my node-red environment.

What am I missing??

H

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [25 June 2023 15:34 UTC](https://discourse.nodered.org/t/multiple-path-parameters-on-http-in-node-for-api/79404/2 "2023-06-25T15:34:13Z")

</div>

Under the hood, this is just an express endpoint so `api/:color/:shape` should work - so long as the URL has both parts.  
But if you want it `shape` to be optional (omitted from the URL), you need to add a question mark `api/:color/:shape?`

Note: this matcher `api/:color/:shape?` leaves little room for other more specific routes (basically it would intercept `api/user/1` - clearly not intended.

I would recommend you at minimum specify a version and 1 fixed part to the path (to permit other future routes) e.g. `api/v1/something/:color/:shape?`

---

<div class="post-metadata">

### Author: ![hughsheehy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hughsheehy/32/58679_2.png) [@hughsheehy](https://discourse.nodered.org/u/hughsheehy)
#### Post date: [25 June 2023 18:08 UTC](https://discourse.nodered.org/t/multiple-path-parameters-on-http-in-node-for-api/79404/3 "2023-06-25T18:08:30Z")

</div>

Yeah - I thought it should be straightforward and indeed - all this is downstream of a v1/specificfunction/ path in the APIs.

So it's really /v1/checkshape/:color/:shape

But I still don't get it to work. All I'm doing is setting msg.payload to be msg.req.params and passing it back in the http response.

If I have one path, no problem at all. Soon as I add that second path? No response. Not even a debug message. I'm sending the messages from postman mostly, but I tried from command line (with Curl) as well.

Me be puzzled. I'm on 3.0.0.

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [25 June 2023 18:11 UTC](https://discourse.nodered.org/t/multiple-path-parameters-on-http-in-node-for-api/79404/4 "2023-06-25T18:11:48Z")

</div>

If you are not getting anything, then maybe you have another route swallowing it. Try disabling other http-in nodes.

---

<div class="post-metadata">

### Author: ![hughsheehy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hughsheehy/32/58679_2.png) [@hughsheehy](https://discourse.nodered.org/u/hughsheehy)
#### Post date: [27 June 2023 10:53 UTC](https://discourse.nodered.org/t/multiple-path-parameters-on-http-in-node-for-api/79404/5 "2023-06-27T10:53:02Z")

</div>

I don't understand why, but I added "2" to the rmain route, deployed, deleted the "2", deployed again, and now it works.

As I was editing previously it's possible that there had been another copy of the http-in node at one stage, but it hadn't existed for a while.

In any case, it all works fine now! As it should, it "just works".

Thanks.

H

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [11 July 2023 10:53 UTC](https://discourse.nodered.org/t/multiple-path-parameters-on-http-in-node-for-api/79404/6 "2023-07-11T10:53:33Z")

</div>

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